This is a skeleton service that uses Java 8 and Spring Boot. It contains the following:
- Maven for dependency management
- JUnit and Spring Test for unit and integration testing
- Spring profiles for multi-environment setup
- EditorConfig for code formatting
- Jacoco for coverage (must be > 80%)
- Swagger for API docs
- Access logger for HTTP logs
- Spring Actuator for monitoring and healthcheck
- Spring Security for securing the Actuator endpoints
- Lombok for amazing POJOs
- Dockerfile and Docker Compose to run the service
In order to build the project, you will have to install the following:
- Java 8
- Maven
- Docker
- This project includes Lombok Annotations, this means that in order for your IDE to correctly compile your project you'll need to add the Lombok plugin to your IDE.
- IntelliJ: https://projectlombok.org/setup/intellij
- NetBeans: https://projectlombok.org/setup/netbeans
- Eclipse: https://projectlombok.org/setup/eclipse
- For annotation processing to work for lombok annotations, you'll need to enable annotation processing at a project level in your IDE.
- File -> Other Settings -> Default Settings
- Build, Execution, Deployment -> Compiler -> Annotation Processors
- Enable annotation processing.
- Clean, build, invalidate cache and restart after that.
mvn clean install
docker build -t quay.io/paulpop/java-spring-service .
mvn spring-boot:run
Environment variables:
- ENVIRONMENT = Spring Profile to use for configurations default, dev or prod (required)
- ADMIN_PASSWORD = Spring Actuator admin password
docker-compose up --build
If you need to change any of the environment variables, please use the .env
file.
Configuration file 'application.yml' is present in config directory together with profile specific YML files. The application.yml is used as a parent and the profile specific ones are used for overrides.
To run the unit and integration tests, execute:
mvn verify
To run the unit tests only, execute:
mvn verify -DskipITs
To run the integration tests only, execute:
mvn verify -DskipUTs
Once you run the application, the documentation of the API can be found at: http://localhost:8080/swagger-ui.html