This is my customized springboot starter with all libraries and utilities that I usually include in my projects. My plan is to keep ip updated and well documented so that it can be understood and used by anyone.
This project is intented for REST services. The latest version of each component is encouraged.
- Java 21
- SpringBoot 3
These should not change too much. They are the base of this custom starter.
This is the complete list of components and a high level overview of the functionality that each one provides:
- Lombok
- Common object manipulation methods.
- JPA + Spring Data
- Persistence manager.
- Query By Example (QBE) filtering.
- Pagination.
- Input Validation
- DTO validation.
- DTO inheritance (for error responses).
- Junit 5 (Jupiter)
- Unit testing.
- OpenAPI
- API documentation + swagger UI.
- H2
- Actual persistence; DB engine.
- Custom configuration:
- Using Oracle mode.
- Liquibase
- DB changes manager (kinda like GIT, but for the DB).
- Custom configuration:
- Check application.yaml.
- Templates for basic DB operations.
- Mapstruct
- Object to object mapping.
- Custom configuration:
- Unmapped target or source raises compilation error (must be explicitly ignored).
- Default component model spring (avoids the need to declare it inside each mapper; automatically creates the bean).
- JaCoCo
- Code coverage (report and checker).
- Custom configuration:
- Exclude mapper *Impl classes (that is, excludes autogenerated mapper code, but still checks custom static or default methods).
- Check that ALL metrics at BUNDLE level are > 90%. This ratio is defined as a property (
jacoco-coverage-check-threshold-bundle).
- Google Java Format
- Code formatter.
- Checkstyle
- Checks for style, code and logic errors.
- Custom configuration:
- Using google_checks to match Google's style and format.
- Transaction examples
- 2 DB modifications.
- New transaction inside existing one.
- VerifyNoMoreInteractionsExtension
- Extension to automatically verify the expected interactions based on the when-then instructions.
- Caveat: manual verify implementation still required when MockMvc is used.
- Extension to automatically verify the expected interactions based on the when-then instructions.
- FieldsUtils
- Provides methods to update and null check objects.
- Enum Validator
- Validates enum-entity integrity against the DB at APP startup.
- Caveat: each enum validation must be implemented manually. Maybe automation is possible?
- Validates enum-entity integrity against the DB at APP startup.
Some components are intented to be just an example and they should be removed or replaced by something that suits your specific case.
- H2
- Fine for development and tinkering, but not so fine for production.
- Liquibase scripts
- While the configuration is fine, the migration scripts should not be migrated.
- You can keep or delete the templates at your liking; they're not actually executed.
This project uses Google Java Format. You can find the official install configuration on Google's GitHub: https://github.com/google/google-java-format
For Eclipse (and STS) some additional configuration is needed. This might not apply to other IDEs.
Additional configuration is required for Eclipse IDE to properly organize imports:
To comply with Google's style, go to Window > Preferences > Java > Code Style > Organize Imports, delete all default groups and add a single * static import group and a single * import group. Apply changes.
Additional configuration is required for Eclipse IDE to properly indent new lines:
To comply with Google's style, go to Window > Preferences > Java > Code Style > Formatter, click on Edit.
In the first list Indentation change Tab Size to 2.
- EclEmma Java Code Coverage
- SonarQube
- Checkstyle
- Might need to select the google_checks profile.
I'm usually working on the first element of the following list:
- Specifications.
- Some examples.
- Generic specifications? Like DSL Builder.
- Controller JUnit improvement?
- Get the response from the call and check the response code as an assert.
- Junit examples.
- any error for primitives.
- Cache.
- Internationalization?
- Security?
- peer token.
- access token (service activity).
- https.
- Fix exception handler testing method.
- Generic components (generic mapper, generic repo, etc).
- Upload utils to maven central.