Centralized configuration management for the Ecomera microservices ecosystem using Spring Cloud Config Server.
Provides externalized configuration for all Ecomera microservices across different environments (dev, staging, production). Configurations are stored in src/main/resources/config/ and served via REST API.
- Spring Boot 3.5.11
- Spring Cloud Config Server 2025.0.1
- Native Profile - File-based configuration storage
- Eureka Client - Service registration
- Java 17+
- Maven 3.6+
- Eureka Server running on port 8761
mvn spring-boot:runConfig server available at: http://localhost:8888
Eureka dashboard: http://localhost:8761 (should show ECOMERA-CONFIG-SERVER)
| Property | Default | Description |
|---|---|---|
server.port |
8888 | Config server port |
spring.profiles.active |
native | Configuration source (native = classpath files) |
eureka.client.service-url.defaultZone |
http://localhost:8761/eureka/ | Eureka server URL |
src/main/resources/
├── application.yml # Shared across all services
└── config/
├── ecomera-eureka-service-registry.yml # Eureka-specific config
├── auth-service.yml # Auth Service config
└── *-service.yml # Other service configs
Config files follow pattern: {spring.application.name}.yml
Example: Service with spring.application.name=auth-service fetches auth-service.yml
Microservices fetch configuration by adding to their application.yml:
spring:
application:
name: auth-service # Matches auth-service.yml
config:
import: optional:configserver:http://localhost:8888On startup:
- Service connects to Config Server
- Fetches
application.yml(shared config) - Fetches
auth-service.yml(service-specific config) - Merges both configurations
curl http://localhost:8888/actuator/health# Get auth-service configuration
curl http://localhost:8888/auth-service/default
# Get eureka configuration
curl http://localhost:8888/ecomera-eureka-service-registry/defaultResponse: JSON with merged configuration properties
docker build -t ecomera-config-server .docker run -p 8888:8888 \
-e EUREKA_SERVER_URL=http://eureka:8761/eureka/ \
ecomera-config-server| Endpoint | Description |
|---|---|
/{application}/{profile} |
Get configuration for service |
/actuator/health |
Health check |
/actuator/info |
Service information |
Example:
http://localhost:8888/auth-service/defaulthttp://localhost:8888/auth-service/devhttp://localhost:8888/auth-service/prod
- Eureka Service Registry - Service discovery
- API Gateway - Entry point for microservices
- Auth Service - Authentication & authorization
Microservices → Config Server (port 8888) → classpath:/config/*.yml
↓
Eureka Server (port 8761)
All services fetch their configuration from Config Server on startup and register with Eureka for service discovery.
- Create
{service-name}.ymlinsrc/main/resources/config/ - Add service-specific properties
- Restart Config Server (or use
@RefreshScopefor runtime updates) - Service will fetch config on next startup
MIT License - see LICENSE file for details