This repository contains three Spring Boot microservices demonstrating Spring Cloud Config architecture:
- Config Server - Centralized configuration management server
- Config Client - Client application that retrieves configuration from the server
- Config Client 2 - Second demo client application with independent configuration
- Java 21 or higher
- Maven 3.9.11
- SDKMAN (configured in
.sdkmanrc)
Start individual services:
# Terminal 1 - Start Config Server
./start-config-server.sh
# Terminal 2 - Start Config Client
./start-config-client.sh
# Terminal 3 - Start Config Client 2 (Optional)
./start-config-client-2.shStart all services at once:
./start-all-services.shThis will open separate terminal windows for each service (macOS only).
Run with specific profile:
./run-with-profile.shInteractive script to choose service and profile (default/dev/prod).
Stop all running services:
./stop-all-services.sh1. Start Config Server
cd config-server
mvn clean install -DskipTests
mvn spring-boot:runThe Config Server will start on http://localhost:8888
2. Start Config Client
In a new terminal:
cd config-client
mvn clean install -DskipTests
mvn spring-boot:runThe Config Client will start on http://localhost:8080
3. Start Config Client 2 (Optional Demo)
In another terminal:
cd config-client-2
mvn clean install -DskipTests
mvn spring-boot:runThe Config Client 2 will start on http://localhost:8081
# Build all modules from root
mvn clean install -DskipTests
# Run specific module
mvn spring-boot:run -pl config-server
mvn spring-boot:run -pl config-client
mvn spring-boot:run -pl config-client-2Once both applications are running:
# Test Config Client
curl http://localhost:8080/api/message
curl http://localhost:8080/api/config
# Test Config Client 2
curl http://localhost:8081/api/message
curl http://localhost:8081/api/config
# Test Config Server directly
curl http://localhost:8888/config-client/default
curl http://localhost:8888/config-client/dev
curl http://localhost:8888/config-client/prod
curl http://localhost:8888/config-client-2/default
curl http://localhost:8888/config-client-2/dev
curl http://localhost:8888/config-client-2/prod./run-with-profile.sh
# Then select service and profile from the menucd config-client
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=dev
# For Config Client 2
cd config-client-2
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=devcd config-client
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=prod
# For Config Client 2
cd config-client-2
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=prodUpdate configuration on the Config Server, then refresh the client:
# Refresh Config Client
curl -X POST http://localhost:8080/actuator/refresh
# Refresh Config Client 2
curl -X POST http://localhost:8081/actuator/refreshspringboot-microservice/
├── config-server/ # Spring Cloud Config Server
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ └── resources/
│ │ │ ├── application.yml
│ │ │ └── config/
│ │ │ ├── config-client.yml
│ │ │ ├── config-client-dev.yml
│ │ │ ├── config-client-prod.yml
│ │ │ ├── config-client-2.yml
│ │ │ ├── config-client-2-dev.yml
│ │ │ └── config-client-2-prod.yml
│ │ └── test/
│ └── pom.xml
│
├── config-client/ # Spring Cloud Config Client
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ └── resources/
│ │ │ ├── application.yml
│ │ │ └── bootstrap.yml
│ │ └── test/
│ └── pom.xml
│
├── config-client-2/ # Spring Cloud Config Client 2 (Demo)
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ └── resources/
│ │ │ ├── application.yml
│ │ │ └── bootstrap.yml
│ │ └── test/
│ └── pom.xml
│
├── start-config-server.sh
├── start-config-client.sh
├── start-config-client-2.sh
├── start-all-services.sh
├── run-with-profile.sh
├── stop-all-services.sh
└── README.md
- Centralized configuration management
- Support for multiple environments (default, dev, prod)
- Git backend support (https://github.com/chakricodesjava/config-repo)
- Native file system backend (can be toggled)
- REST API for configuration retrieval
- Serves configuration for multiple client applications
- Dynamic configuration loading from Config Server
- Profile-based configuration
- Runtime configuration refresh
- RESTful endpoints to view current configuration
- Runs on port 8080
- Independent demo client application
- Same capabilities as Config Client
- Separate configuration files
- Runs on port 8081
- Spring Boot 3.3.4
- Spring Cloud Config 2023.0.3
- Java 21
- Maven 3.9.11
| Script | Description |
|---|---|
start-config-server.sh |
Start Config Server with helpful output |
start-config-client.sh |
Start Config Client with API endpoint info |
start-config-client-2.sh |
Start Config Client 2 with API endpoint info |
start-all-services.sh |
Start all services in separate terminals |
run-with-profile.sh |
Interactive script to run any service with any profile |
stop-all-services.sh |
Stop all running Spring Boot services |
All startup scripts include:
- ✅ Automated build with
mvn clean install -DskipTests - ✅ Error handling and validation
- ✅ Helpful status messages with emojis
- ✅ API endpoint information
- ✅ Port and URL details
- ✅ Press Ctrl+C instructions