This project is designed to explore and test different approaches for converting Entity objects into DTOs and vice versa. It demonstrates several methods for achieving this goal in a Spring Boot application.
The following methods for entity-to-DTO conversion are implemented:
- Constructor: Directly using constructors in DTO classes.
- Static Method: Utilizing static factory methods for conversion.
- @Builder (Lombok): Leveraging Lombok's @Builder annotation for building DTOs.
- Manual Mapper: Writing custom mapper classes for conversion.
- MapStruct: Using the MapStruct library for automatic mapping.
- Spring Data JPA Projection: Utilizing JPA projections to create DTOs directly from queries.
- Java Version: Java 23
- Frameworks: Spring Boot 3, JUnit 5
- API Documentation: Swagger UI
- Clone the repository:
git clone https://github.com/angelicamarttins/entity-dto-converter
cd entity-dto-converter
- Start the application:
./gradlew bootRun
- Open your browser and navigate to:
http://localhost:8080/swagger-ui/index.html
- Explore the endpoints:
- Select an endpoint;
- Click on
Try it out; - Modify the request payload if needed;
- Click
Executeto see the response.
https://github.com/melix/jmh-gradle-plugin https://github.com/artyushov/idea-jmh-plugin https://github.com/openjdk/jmh