A production-ready Spring Boot application demonstrating best practices for containerized Java applications with comprehensive test coverage.
- Java 17 - LTS version with modern language features
- Spring Boot 3.5.6 - Latest Spring Boot framework
- Maven 3 - Dependency management and build automation
- JUnit 5 - Modern testing framework
- JaCoCo 0.8.12 - Code coverage analysis with 80% minimum threshold
- Docker - Alpine-based containerization with optimized JRE image
- Multi-stage Docker build with Eclipse Temurin JRE 17
- Security hardened - runs as non-root user (
nobody:nogroup) - Optimized startup - uses
execfor proper signal handling (PID 1) - Runtime configuration - JVM options via
$JAVA_OPTSenvironment variable
- Unit tests with
@WebMvcTestfor controller layer - Integration tests with
@SpringBootTestfor application context - Coverage enforcement - JaCoCo checks minimum 80% code coverage
- Excludes - Application main class excluded from coverage metrics
- Automated test execution during Maven build lifecycle
- Coverage reports - HTML, XML, and CSV formats
- CI/CD ready - Fail-fast on coverage violations
# Build the application
./mvnw clean package
# Run tests with coverage
./mvnw clean test
# Run with coverage check
./mvnw verify
# Run the application
java -jar target/java-maven-springboot-0.0.1-SNAPSHOT.jar# Build image
docker build -t java-maven-springboot:latest .
# Run container
docker run -p 8080:8080 \
-e JAVA_OPTS="-Xmx512m -Xms256m" \
java-maven-springboot:latestGET /api/hello- Returns greeting message
View coverage reports after running tests:
open target/site/jacoco/index.htmlCurrent coverage: 100% of application code
This demo is part of the KubeRocketCI platform, which provides a complete CI/CD solution for Kubernetes-native applications.
For comprehensive guides on building cloud-native applications with KubeRocketCI, visit the official documentation.
Apache License 2.0