Minimal microservices system that demonstrates classic Spring Cloud Netflix components and patterns using a Maven multi‑module build.
The domain contains two business services: a Department Service and a User Profile Service. The User Profile Service enriches user profiles by calling the Department Service.
Java 21, Maven 3, Spring Boot 2.7.x, Spring Cloud 2021.x
Infra for local dev: MongoDB 5.x, MySQL 5.7.x, Zipkin, Prometheus, Grafana, SonarQube (via compose.yaml).
Utilities: Liquibase, Testcontainers, WireMock, Micrometer, Checkstyle, SpotBugs, PMD, Qulice, JaCoCo, Modernizer.
All modules are declared in the root pom.xml as a multi‑module reactor.
| Module | Type | Purpose | Default port | Notes |
|---|---|---|---|---|
service-registry |
Spring Boot app | Eureka Server for service discovery | 8080 | Set SERVER_PORT to avoid clashes locally |
config-server |
Spring Boot app | Centralized configuration backed by Git | 8080 | Imports Git repo defined in config-server/application.yml |
api-gateway |
Spring Boot app | Edge gateway (Zuul) + Hystrix circuit breakers | 8080 | Routes /api/v1/departments/** and /api/v1/user-profiles/** |
hystrix-dashboard |
Spring Boot app | Hystrix Dashboard | 8080 | Exposes Hystrix stream consumption |
department-service |
Spring Boot app | MySQL + Liquibase backed Department API | 8080 | JPA, Liquibase migrations under migrations/ |
user-profile-service |
Spring Boot app | MongoDB backed User Profile API | 8080 | Calls Department service via gateway/discovery |
boot-starter-cache |
Library (starter) | Opinionated cache starter (JCache/Ehcache) | — | Auto‑config via spring.factories |
boot-starter-mvc-rest |
Library (starter) | REST/MVC common config (errors, JSON, filters) | — | Auto‑config via spring.factories |
Notes:
- By default each service binds to
8080(seeserver.port). When running multiple apps locally, pass a uniqueSERVER_PORTper service. - Actuator endpoints are enabled for health/metrics; Prometheus and Zipkin tracing are preconfigured.
api-gateway forwards to registered services via Eureka:
lb://department-service→/api/v1/departments/**(Hystrix fallback/departmentServiceFallback)lb://user-profile-service→/api/v1/user-profiles/**(Hystrix fallback/userProfileServiceFallback)
- Start local infra (MongoDB, MySQL, Zipkin, Prometheus, Grafana, SonarQube):
docker compose -f compose.yaml up -d- Build everything (skipping tests if you just want binaries):
./mvnw -q -DskipTests clean install- Run the services in separate terminals; assign unique ports via
SERVER_PORT:
# Discovery + Config + Dashboard
SERVER_PORT=3001 ./mvnw -pl service-registry -am spring-boot:run
SERVER_PORT=3002 ./mvnw -pl config-server -am spring-boot:run
SERVER_PORT=3003 ./mvnw -pl hystrix-dashboard -am spring-boot:run
# Domain services
SERVER_PORT=3004 ./mvnw -pl department-service -am spring-boot:run
SERVER_PORT=3005 ./mvnw -pl user-profile-service -am spring-boot:run
# Edge gateway
SERVER_PORT=3000 ./mvnw -pl api-gateway -am spring-boot:runSuggested local URLs:
- Service Registry (Eureka):
http://localhost:3001 - Config Server:
http://localhost:3002 - Hystrix Dashboard:
http://localhost:3003 - API Gateway:
http://localhost:3000 - Zipkin:
http://localhost:9411 - Prometheus:
http://localhost:9090(via host network in compose) - Grafana:
http://localhost:3000(if not using the gateway port) — adjust as needed
Example requests:
# Departments
curl http://localhost:3000/api/v1/departments
# User Profiles (enriched with department info)
curl http://localhost:3000/api/v1/user-profilesRun full test suite with Testcontainers:
./mvnw verify -P use-testcontainerssample-netflix-oss-usage
├─ service-registry
├─ config-server
├─ api-gateway
├─ hystrix-dashboard
├─ department-service
├─ user-profile-service
├─ boot-starter-cache
└─ boot-starter-mvc-rest
The code follows the Google Java Style Guide. Quality gates and analysis are configured via:
- SonarQube, PMD, Checkstyle, SpotBugs, Qulice, JaCoCo, Modernizer
The project includes Cursor AI assistant rules for consistent code quality:
- Java Best Practices: Rules for code organization, design patterns, performance, security, testing, and common pitfalls
- Spring Boot Best Practices: Guidelines for Spring Boot application structure, configuration, dependency injection, testing, and API design
These rules help maintain coding standards and provide automated guidance when using the Cursor AI assistant.
Project uses three‑segment CalVer: YY.MM.MICRO.
—
If you run into port or config conflicts locally, override via environment variables:
SERVER_PORT,EUREKA_SERVER_URL,CONFIGSERVER_IMPORT, DB connection strings, etc.
Happy hacking!