A comprehensive REST API demonstration project built with Spring Boot 3.x, showcasing full CRUD operations with modern Java enterprise technologies.
This project serves as a technical validation and learning demonstration for Spring Boot API development, implementing a complete User management system with best practices.
| Technology | Version | Purpose |
|---|---|---|
| Java | 17 (LTS) | Programming Language |
| Spring Boot | 3.5.6 | Framework |
| Spring Data JPA | 3.x | Data Access Layer |
| Jakarta EE | 9+ | Enterprise Specifications |
| Maven | 3.9.11 | Build Tool |
| MySQL | 8.x | Database |
| Hibernate | 6.x | ORM Framework |
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Controller ββββββ Service ββββββ Repository β
β (REST API) β β (Business Logic)β β (Data Access) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β HTTP Client β β Validation β β MySQL β
β (Postman) β β Error Handle β β Database β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- CREATE - Add new users with validation
- READ - Retrieve all users or specific user by ID
- UPDATE - Modify existing user information
- DELETE - Remove users from database
- Input Validation - Username and email validation
- Duplicate Prevention - Username uniqueness check
- Error Handling - Comprehensive exception management
- HTTP Status Codes - Proper REST API responses
- Service Layer - Business logic separation
| Method | Endpoint | Description | Response |
|---|---|---|---|
GET |
/users |
Get all users | 200 OK |
GET |
/users/{id} |
Get user by ID | 200 OK / 404 Not Found |
POST |
/users |
Create new user | 200 OK / 400 Bad Request |
PUT |
/users/{id} |
Update user | 200 OK / 404 Not Found |
DELETE |
/users/{id} |
Delete user | 200 OK / 404 Not Found |
{
"username": "john_doe",
"name": "John Doe",
"email": "john@example.com"
}"User created successfully with ID: 1"- Java 17+ installed
- Maven 3.6+ installed
- MySQL 8.x running
- Git installed
git clone https://github.com/YOUR_USERNAME/spring-boot-crud-api-demo.git
cd spring-boot-crud-api-demoCREATE DATABASE crash_api_course;Update src/main/resources/application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/crash_api_course
spring.datasource.username=YOUR_USERNAME
spring.datasource.password=YOUR_PASSWORD# Using Maven Wrapper (Recommended)
./mvnw spring-boot:run
# Using installed Maven
mvn spring-boot:runApplication will start on http://localhost:8080
- Open Postman
- Import the following collection:
{
"info": { "name": "Spring Boot CRUD API" },
"variable": [{ "key": "baseUrl", "value": "http://localhost:8080" }],
"item": [
{
"name": "Get All Users",
"request": { "method": "GET", "url": "{{baseUrl}}/users" }
},
{
"name": "Create User",
"request": {
"method": "POST",
"url": "{{baseUrl}}/users",
"header": [{ "key": "Content-Type", "value": "application/json" }],
"body": {
"mode": "raw",
"raw": "{\"username\":\"alice\",\"name\":\"Alice Smith\",\"email\":\"alice@example.com\"}"
}
}
}
]
}src/
βββ main/
β βββ java/com/saturn/crash_api_course/
β β βββ CrashApiCourseApplication.java # Main Application
β β βββ controller/
β β β βββ UserController.java # REST Controllers
β β βββ service/
β β β βββ UserService.java # Business Logic
β β βββ repository/
β β β βββ UserRepository.java # Data Access
β β βββ model/
β β βββ User.java # JPA Entities
β βββ resources/
β βββ application.properties # Configuration
βββ test/
βββ java/
βββ CrashApiCourseApplicationTests.java # Tests
This project demonstrates:
- β Spring Boot 3.x modern features
- β RESTful API design principles
- β 3-Layer Architecture (Controller-Service-Repository)
- β JPA/Hibernate ORM usage
- β Dependency Injection patterns
- β Input Validation best practices
- β Error Handling strategies
- β HTTP Status Codes proper usage
- β Maven build management
mysql -u root -p -e "SELECT 1;"tail -f logs/spring-boot-application.log# Clean and compile
./mvnw clean compile
# Run tests
./mvnw test
# Package JAR
./mvnw clean package