A hands-on walkthrough from cloning the project to building a Docker image. Estimated time: 30 minutes.
Prerequisites: JDK 21+, Docker, Git. See Toolchain for installation instructions.
- Clone & Verify Setup
- Build the Project
- Run the REST API
- Explore the API
- Run Other Examples
- Add a Feature
- Run Quality & Security Scans
- Docker Build & Run
- Next Steps
git clone <repository-url>
cd java-enterprise-templateVerify your tools:
java -version # 21+ required
./mvnw --version # Maven wrapper — no global install needed
docker --version # Required for integration tests and Docker buildsIf any command fails, see Toolchain — Installation.
./mvnw clean verifyThis compiles all 9 modules — the app/ core Spring Boot application (template-app) plus the 8 example modules — runs unit tests, and generates coverage reports. On first run, Maven downloads dependencies — expect 3–5 minutes. Subsequent builds are faster.
What just happened:
| Phase | What it does |
|---|---|
compile |
Compiles all modules (Java 21 source level) |
test |
Runs unit tests via Surefire |
verify |
Runs JaCoCo coverage checks |
To run only unit tests (faster):
./mvnw testTo build a single module:
./mvnw -pl examples/restful-api -am testThe -am flag ("also make") builds any parent/dependency modules needed.
./mvnw -pl examples/restful-api spring-boot:runYou should see:
Started RestApiApplication in X.XX seconds
The server is now running at http://localhost:8080.
Open Swagger UI in your browser: http://localhost:8080/swagger-ui.html
With the server running (from step 3), open a new terminal:
# Create a product
curl -s -X POST http://localhost:8080/api/v1/products \
-H 'Content-Type: application/json' \
-d '{"name": "Widget", "price": 9.99}' | jq .
# List all products
curl -s http://localhost:8080/api/v1/products | jq .
# Get a specific product (use the ID from the create response)
curl -s http://localhost:8080/api/v1/products/1 | jq .
# Update a product
curl -s -X PUT http://localhost:8080/api/v1/products/1 \
-H 'Content-Type: application/json' \
-d '{"name": "Super Widget", "price": 19.99}' | jq .
# Delete a product
curl -s -X DELETE http://localhost:8080/api/v1/products/1Stop the server with Ctrl+C when done.
Most modules are libraries, not servers. Run their tests to see them in action:
# Design patterns — 15 GoF patterns with modern Java
./mvnw -pl examples/patterns test
# Database — JPA, JDBC, transactions (uses H2 in-memory)
./mvnw -pl examples/database test
# HPC — parallel streams, CompletableFuture, concurrency
./mvnw -pl examples/hpc test
# Simulation — Monte Carlo, discrete event simulation
./mvnw -pl examples/simulation test
# Testing — JUnit 5 features, Mockito, ArchUnit
./mvnw -pl examples/testing testFor integration tests (requires Docker running):
./mvnw -pl examples/testing verify -P integration-testsEach module has its own README with details — see examples/.
Let's add a health-check endpoint to the REST API to see the full workflow.
Create examples/restful-api/src/main/java/com/example/template/restfulapi/controller/HealthController.java:
package com.example.template.restfulapi.controller;
import java.time.Instant;
import java.util.Map;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Simple health endpoint returning application status and server time.
*/
@RestController
public class HealthController {
/**
* Returns a health status response.
*
* @return map containing status and current timestamp
*/
@GetMapping("/api/health")
public ResponseEntity<Map<String, Object>> health() {
return ResponseEntity.ok(Map.of(
"status", "UP",
"timestamp", Instant.now().toString()));
}
}# Compile and run tests for the module
./mvnw -pl examples/restful-api test
# Start the server and test your endpoint
./mvnw -pl examples/restful-api spring-boot:run
# In another terminal:
curl -s http://localhost:8080/api/health | jq .Expected response:
{
"status": "UP",
"timestamp": "2026-04-11T23:00:00Z"
}Always run the full build before committing:
./mvnw clean verifyFor more on extending the project (new modules, services, dependencies), see Extending the Template.
./mvnw verify -Psecurity-scan-quickThis runs bug detection, code style checks, and static analysis across all modules. Fix any violations before committing.
./mvnw verify -Psecurity-scanThis checks all dependencies against the National Vulnerability Database. First run downloads the CVE database (~10 minutes); subsequent runs are incremental.
# Check formatting
./mvnw spotless:check -Pformat
# Auto-fix formatting
./mvnw spotless:apply -PformatAfter ./mvnw verify, open the JaCoCo report:
open examples/restful-api/target/site/jacoco/index.htmlFor detailed scan configuration and suppression guides, see Security Scanning and Toolchain — Quality Tools.
# Package the REST API JAR (skip tests — we already ran them)
./mvnw package -pl examples/restful-api -am -DskipTests
# Build the Docker image
docker build -t java-template-api:latest \
-f examples/restful-api/Dockerfile examples/restful-api
# Run the container
docker run -p 8080:8080 java-template-api:latest
# Test it
curl -s http://localhost:8080/api/v1/products | jq .The image uses eclipse-temurin:21-jre-alpine, runs as a non-root user, and includes a health check on /actuator/health.
Stop the container with Ctrl+C or docker stop <container-id>.
| Want to... | Read |
|---|---|
| Add a new module or endpoint | Extending the Template |
| Understand the architecture | Architecture Patterns |
| Learn coding conventions | Best Practices |
| Set up your IDE | Toolchain — IDE Setup |
| Configure CI/CD | Development Workflow |
| Write Javadoc and READMEs | Documentation Standards |
| Run security scans in CI | Security Scanning |
See also: README · Toolchain · Extending · Development Workflow