The project started as a simple CRUD API for a Person entity connected to MySQL. It evolves as new backend concepts are studied and added to the application.
- Technologies
- Features
- API endpoints
- API versioning
- Project structure
- Getting started
- Tests
- Next steps
- Author
- Java 21
- Spring Boot 3.4.0
- Spring Web
- Spring Data JPA
- Bean Validation
- MySQL
- Maven
- Dozer
- CRUD operations for people
- Layered architecture
- Request and response DTOs
- Bean validation
- Exception handling
- Object mapping with Dozer and custom mappers
- API versioning with v1 and v2 response contracts
- MySQL persistence with JPA
The API runs by default at http://localhost:8080.
| Method | Endpoint | Description |
|---|---|---|
GET |
/person |
Find all people |
GET |
/person/{id} |
Find a person by ID |
GET |
/person/v1/{id} |
Find a person using the v1 response |
GET |
/person/v2/{id} |
Find a person using the v2 response |
POST |
/person |
Create a person |
PUT |
/person/{id} |
Update a person |
DELETE |
/person/{id} |
Delete a person |
Requests with a body must use the following header:
Content-Type: application/jsonPOST http://localhost:8080/person{
"firstName": "Arthur",
"lastName": "Almeida",
"adress": "Rua A, 123 - Bahia, Brasil",
"gender": "Male"
}Note: the request DTO currently exposes
adresswith this spelling. Response DTOs useaddress.
PUT http://localhost:8080/person/1{
"firstName": "Arthur",
"lastName": "Almeida",
"adress": "Rua B, 456 - Bahia, Brasil",
"gender": "Male"
}Versioning is currently available on the find-by-ID endpoint and demonstrates how different response contracts can coexist.
GET http://localhost:8080/person/v1/1{
"id": 1,
"firstName": "Arthur",
"lastName": "Almeida",
"address": "Rua A, 123 - Bahia, Brasil",
"gender": "Male"
}GET http://localhost:8080/person/v2/1Version 2 adds the birthDay field:
{
"id": 1,
"firstName": "Arthur",
"lastName": "Almeida",
"address": "Rua A, 123 - Bahia, Brasil",
"gender": "Male",
"birthDay": "2026-08-07T00:00:00.000+00:00"
}src/main/java/com/thurdass/springboot_lab
├── config
│ └── DozerConfig.java
├── controllers
│ ├── PersonController.java
│ └── TestLogController.java
├── dto
│ ├── PersonRequest.java
│ ├── PersonResponse.java
│ ├── v1
│ │ └── PersonDTO.java
│ └── v2
│ └── PersonDTOV2.java
├── exception
│ ├── ExceptionResponse.java
│ ├── ResourceNotFoundException.java
│ └── handler
│ └── customEntityResponseHandler.java
├── mapper
│ └── custom
│ └── PersonMapper.java
├── model
├── repository
└── services
- Java 21
- Maven
- MySQL
git clone https://github.com/thurdass/springboot-lab.git
cd springboot-labCREATE DATABASE springboot_lab;The application reads the database credentials from environment variables. Defaults are available for local development, but setting both variables is recommended:
export DB_USERNAME=root
export DB_PASSWORD=your_passwordMake sure MySQL is running before starting the application.
mvn spring-boot:runThe API will be available at http://localhost:8080.
Run the test suite with:
mvn test- Add Spring Security with JWT
- Add Swagger/OpenAPI documentation
- Expand unit and integration tests
- Add Docker support
- Add versioning to create and update endpoints
Arthur da Silva Mendes de Almeida — IT student
- Learning backend development with Java and Spring Boot
- GitHub: @thurdass
- LinkedIn: View profile
