API CRUD example using:
- DDD structure
- Custom exceptions
- Rest controller advice
- Api docs with swagger
- Custom interceptor to obtain a detailed log of the application's requests and responses.
- Unit test (JUnit5 + Mockito)
- Sonarqube analysis
- Postman collection
- Java 11
- Maven 3.6.3
- Postgresql 13.2 (You can use another database, but you must change the dependencies in pom.xml)
- Postman (Optional)
- Sonarqube (Optional)
- Intellij Idea (Optional)
- Lombok (Recommended)
.
├── domain # Business layer
├── dto # DTO
├── service # Logic layer
├── impl # Implementation of service
├── exception # Handle custom exception
├── controller # Rest Controller Advice
├── dto # Custom DTO
├── interceptor # Custom Interceptor
├── dto # Logger DTO for custom interceptor
├── service # Service to log trace for custom interceptor
├── persistence # Data access
├── entity # Entities used in app
├── mapper # Mapper entities to DTO
├── impl # Implementation of mappers
├── repository # Repositories (JPA, CrudRepository, etc)
├── util # Constants, formatters, etc
├── web # REST Controller
├── dto # DTO example (Request and Response)
├── interceptor # Interceptor config
├── dto # Logger DTO
├── service # Service to log trace
├── web # Rest Controller
├── postman # Folder to save collection post
- Clone repository.
- Open folder.
- In folder
src/main/resources
it's located SQL file for this app - Run:
mvn clean && mvn install
- Open in your favorite IDE (I use Intellij Idea).
- Use postman to test (Collection included in
postman
folder). - The endpoint is (http://localhost:8010/api-crud/v1/)[http://localhost:8010/api-crud/v1/]
- Documentation of API is in (http://localhost:8010/api-crud/v1/swagger-ui.html)[http://localhost:8010/api-crud/swagger-ui.html]
- Make archetype in maven to facilitate implementation