This is a skeleton for a Spring Boot microservice. It is intended to be used as a starting point for new microservices.
- Java 17
- Spring Boot 3.x
- Gradle 8.x
- Docker
- Reactive Web (WebFlux)
- OpenAPI 3.x documentation & Swagger UI
- Health check endpoint
- Logback logging
- Dockerized (multi-stage build)
- Checkstyle
- OWASP Dependency Check
- Clone this repository
- Rename the project to your project name
- Rename
rootProject.name
insettings.gradle.kts
to your project name
- Update
Dokerfile
to use the correct jar file nameENTRYPOINT ["java", "-jar", "/app/demo-0.0.1SNAPSHOT.jar"]
. - Update
Dockerfile
Gradle tag to the latest version here. - Update
Dockerfile
Java tag to the latest version here.
-
default: This is the default profile that contains settings applicable to all environments. It serves as a baseline configuration for your application.
-
dev: The dev profile is typically used for development environments. It may contain configurations specific to development, such as a local database setup, debugging options, and other settings that make development easier.
-
test: The test profile is usually used for automated testing environments, like unit tests and integration tests. It can have configurations for in-memory databases or test-specific configurations that differ from the production setup.
-
prod: The prod profile is meant for production environments. It contains configurations optimized for performance, security, and reliability. This is where your application runs in a real-world scenario.
Adding exclusions through build.gradle
:
tasks.jacocoTestReport {
dependsOn(tasks.test)
...
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/SkeletonApplication.class',
])
}))
}
}
http://localhost:8081/api-docs
http://localhost:8081/swagger-ui
http://localhost:8081/health
http://localhost:8081/metrics
http://localhost:8081/loggers
- Backend for Frontend (BFF) as an API Gateway
- Database schema per service
- Expose the /health endpoint
- Injection of external configuration at runtime
- Service Contracts Testing Agreement
- Liquibase for database change management
- Dapr for event-driven programming
- Implement Distributed Tracing
- If High Performance is Required, Spring Native
- Early and Frequent DevSecOps
- Development tools
- Project structure
- Logging rules
- Startup Profiles Configuration
- Code documentation with Open API
- Use of UI Swagger
- Input validation in controllers
- Use of Lombok
- Use of Checkstyle
- Project dependency standards
- Simple and clean controller layer
- Service layer focused on business logic
- Constructor injection instead of @Autowired
- Pagination and sorting with Spring Data JPA
- Unit testing with JUnit and Mockito
- JSON log configuration with Logback
- Global exception handling
- Avoid unnecessary additional dependencies
- Review Dependency Updates
- Use of Maven Wrapper