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
- Gradle 8 - Dependency management and build automation
- JUnit 5 - Modern testing framework
- JaCoCo 0.8.12 - Code coverage analysis with 80% minimum threshold
- Checkstyle 10.20.2 - KubeRocketCI standard (4-space indentation)
- 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 Gradle build lifecycle
- Coverage reports - HTML, XML, and CSV formats
- Checkstyle with KubeRocketCI standards (4-space indentation)
- CI/CD ready - Fail-fast on coverage violations
# Build the application
./gradlew clean build
# Run tests with coverage
./gradlew test jacocoTestReport
# Run with coverage check
./gradlew check
# Run checkstyle
./gradlew checkstyleMain checkstyleTest
# Run the application from build
java -jar build/libs/*.jar
# Run the application
./gradlew bootRun# Build image
docker build -t java-gradle-springboot:latest .
# Run container
docker run -p 8080:8080 \
-e JAVA_OPTS="-Xmx512m -Xms256m" \
java-gradle-springboot:latestGET /api/hello- Returns greeting message
View coverage reports after running tests:
open build/reports/jacoco/test/html/index.htmlCurrent coverage: 100% of application code
View checkstyle reports:
open build/reports/checkstyle/main.html
open build/reports/checkstyle/test.htmlCoding Standards:
- 4-space indentation
- Static imports before regular imports
- Line length max 120 characters
- Full Checkstyle compliance (0 violations)
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