Spring Boot 3.x + Spring Cloud Config Server for centralized configuration management.
- QUICKSTART.md - Get started in 5 minutes
- DEVELOPMENT.md - Complete development guide for IntelliJ IDEA
- CLAUDE.md - Architecture and technical details
- README.md - This file (comprehensive reference)
- Spring Cloud Config Server with Git backend
- Custom YAML endpoint that returns merged configuration as
application.yaml - GitHub authentication support via environment variables
- Standard Config Server endpoints (JSON and YAML)
- Health checks via Spring Actuator
- Docker support with multi-stage build
- Git Repository:
https://github.com/dsrvlabs/platform-config - Directory structure: Each service has its own directory with environment-specific files
{service}/ |- application-{env}.yaml |- application-{env}.yaml- Example:
wallet-gateway-api/ |- application-dev.yaml |- application-prod.yaml
- Example:
- Java 21
- Maven 3.9+ (or use included Maven wrapper)
- Docker (optional, for containerized deployment)
-
Clone the repository
git clone https://github.com/dsrvlabs/platform-config-server.git cd platform-config-server -
Set environment variables (optional, for private repositories)
export GIT_USERNAME=your-github-username export GIT_TOKEN=ghp_your_personal_access_token
-
Run the application
./mvnw spring-boot:run
The server will start on
http://localhost:8080/config
-
Build Docker image
docker build -t config-server:latest . -
Run container
docker run --rm -p 8080:8080 \ -e GIT_USERNAME=your-github-username \ -e GIT_TOKEN=ghp_your_token \ config-server:latest
Returns merged configuration as a downloadable application.yaml file.
# Download configuration for wallet-gateway-api service in dev environment
curl -L -o application.yaml \
"http://localhost:8080/config/wallet-gateway-api/dev"
# With custom git label (branch/tag/commit)
curl -L -o application.yaml \
"http://localhost:8080/config/wallet-gateway-api/dev?label=main"Mapping: Request path /{service}/{env} maps to file {service}/application-{env}.yaml
Returns configuration as a downloadable .env file in KEY=VALUE format.
# Download .env configuration for wallet-gateway-api service in qa environment
curl -L -o .env \
"http://localhost:8080/config/wallet-gateway-api-qa.env"
# With custom git label (branch/tag/commit)
curl -L -o .env \
"http://localhost:8080/config/wallet-gateway-api-qa.env?label=main"Mapping: Request path /{service}-{env}.env maps to file {service}/application-{env}.env
How it works:
- Parses properties from
{service}/application-{env}.envfile - Converts to
.envformat (KEY=VALUE) - Returns as plain text file with appropriate filename
Example:
# Request
curl -L -o .env "http://localhost:8080/config/wallet-gateway-api-qa.env"
# Maps to repository file: wallet-gateway-api/application-qa.env
# Returns: KEY1=VALUE1\nKEY2=VALUE2\n.../{name}/{profile} format may not work correctly with the current directory structure ({service}/application-{env}.yaml).
Use the /{name}-{profile}.yaml format (see YAML Format section below) for reliable access to configuration files.
# Returns full environment with property sources (may not work with current structure)
# This format expects files like: wallet-gateway-api-prod.yaml or wallet-gateway-api/prod.yaml
curl "http://localhost:8080/config/wallet-gateway-api/prod"
# With explicit label (branch/tag)
curl "http://localhost:8080/config/wallet-gateway-api/prod/main"URL Pattern: /{name}/{profile} or /{name}/{profile}/{label}
name: Service name (e.g.,wallet-gateway-api)profile: Environment (e.g.,dev,prod)label: Git branch/tag (optional, defaults tomain)
Limitation: This format searches for files like {name}-{profile}.yaml or {name}/{profile}.yaml,
but our repository structure uses {name}/application-{profile}.yaml.
Recommended: Use the /{name}-{profile}.yaml format instead (see YAML Format section).
Returns the original YAML file content directly from the Git repository.
# Download original YAML file for wallet-gateway-api service in prod environment
curl -L -o application.yaml \
"http://localhost:8080/config/wallet-gateway-api-prod.yaml"
# Download for dev environment
curl -L -o application.yaml \
"http://localhost:8080/config/wallet-gateway-api-dev.yaml"URL Pattern: /{name}-{profile}.yaml
name: Service name (e.g.,wallet-gateway-api)profile: Environment (e.g.,dev,prod)
How it works:
요청: /config/wallet-gateway-api-prod.yaml
↓
파싱: name=wallet-gateway-api, profile=prod
↓
Search Paths: ["."] + ["wallet-gateway-api"]
↓
파일 검색: wallet-gateway-api/application-prod.yaml
↓
발견 및 반환: 원본 YAML 파일 내용
Spring Cloud Config automatically resolves the file path using the search-paths configuration:
- Parses the URL to extract
nameandprofile - Searches in root directory (
.) and service directory ({name}) - Matches the file pattern:
{name}/application-{profile}.yaml - Returns the original YAML file content without any transformation
Note: Other Spring Cloud Config endpoint formats like /{name}/{profile}.yml may not work correctly
with the current directory structure ({service}/application-{env}.yaml).
Always use the /{name}-{profile}.yaml format for reliable access.
curl "http://localhost:8080/config/actuator/health"./mvnw testIntegration tests are disabled by default as they require GitHub access. To run them:
-
Set environment variables:
export GIT_USERNAME=your-username export GIT_TOKEN=your-token
-
Enable tests by removing
@Disabledannotation inConfigServerIT.java -
Run tests:
./mvnw test
Configuration is managed in src/main/resources/application.yml:
- Server Port: 8080
- Context Path:
/config - Git URI:
https://github.com/dsrvlabs/platform-config - Default Branch:
main - Clone on Start:
true(downloads repo on startup) - Force Pull:
true(always pulls latest changes)
| Variable | Description | Required |
|---|---|---|
GIT_USERNAME |
GitHub username | No (only for private repos) |
GIT_TOKEN |
GitHub Personal Access Token | No (only for private repos) |
For private repositories, create a Personal Access Token:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Generate new token (classic)
- Select scopes:
repo(Full control of private repositories) - Copy the token and use it as
GIT_TOKEN
config-server/
├── src/
│ ├── main/
│ │ ├── java/com/example/configserver/
│ │ │ ├── ConfigServerApplication.java # Main application class
│ │ │ ├── web/
│ │ │ │ └── ConfigAsYamlController.java # Custom YAML endpoint
│ │ │ └── util/
│ │ │ └── PropertyTree.java # Utility for nested maps
│ │ └── resources/
│ │ └── application.yml # Application configuration
│ └── test/
│ └── java/com/example/configserver/
│ ├── ConfigServerIT.java # Integration tests
│ └── util/
│ └── PropertyTreeTest.java # Unit tests
├── Dockerfile # Multi-stage Docker build
├── pom.xml # Maven configuration
└── README.md # This file
- Java: 21
- Spring Boot: 3.4.0
- Spring Cloud: 2024.0.0
- Build Tool: Maven
- Container: Docker with Eclipse Temurin
- Verify the configuration file exists in the Git repository
- Check directory structure:
{service}/application-{env}.yaml - Ensure the repository is accessible (check credentials for private repos)
- Check logs for Git clone/pull errors
- Verify
GIT_USERNAMEandGIT_TOKENare set correctly - Ensure the token has
reposcope - For public repositories, credentials are not required
- Check if port 8080 is already in use
- Verify Git repository URL is accessible
- Check application logs for detailed error messages
./mvnw clean package./mvnw test./mvnw package -DskipTestsThis project is for internal use.