Demo project for the MapStruct code generator with Spring Boot.
MapStruct is a code generator that simplifies the implementation of mappings between Java bean types based on a convention over configuration approach.
This project was created to validate the feasibility of using this library.
This project also uses the H2 Database as in-memory database for testing purpose.
- Java 17
- Spring Boot 3.2.1
- Lombok version 1.18.30
- MapStruct version 1.5.5.Final
To generate the mapping code run the following command:
mvn clean install
To run the application executes the following code:
mvn spring-boot:run
Access the database via the following url in your browser: http://localhost:8080/h2-console
To create a new customer executes the following command:
curl --location 'http://localhost:8080/customers' \
--header 'Content-Type: application/json' \
--data '{
"name": "João da Silva",
"address": {
"street": "Rua Um",
"number": 100,
"zip_code": 13900100,
"city": "São Paulo"
}
}'
To retrieve a customer by id executes the following command:
curl --location 'http://localhost:8080/customers/{{id}}'
the {{id}}
param is the customer id from the create customer request.
To retrieve the list of customers executes the following command:
curl --location 'http://localhost:8080/customers'