Overview
In adventuretube-microservice, application services (auth-service, member-service, gateway-service, etc.) fetch their configuration from config-server at startup. This document explains how this process works.
Why Config Server?
- Centralized Configuration – All service configs in one place
- Environment-Specific – Different configs for
mac,pi,pi2profiles - Dynamic Updates – Can refresh config without restart
- Git-Backed – Configuration stored in version control
Config Server Architecture
┌─────────────────────┐
│ config-server │
│ Port 9297 │
└──────────┬──────────┘
│
│ serves config
↓
┌───────────────────────────────────────┐
│ auth-service (port 8010) │
│ member-service (port 8070) │
│ gateway-service (port 8030) │
│ web-service (port 8040) │
│ geospatial-service (port 8060) │
└───────────────────────────────────────┘
Configuration Files Location
config-service/src/main/resources/config/
├── auth-service.yml
├── member-service.yml
├── gateway-service.yml
├── web-service.yml
└── geospatial-service.yml
Each file contains service-specific configuration including:
- Eureka client settings
- Database connections
- Service ports
- Custom application properties
Local Development Setup (IntelliJ)
Step 1: Start Infrastructure Services First
1. eureka-server (port 8761)
2. config-server (port 9297)
Step 2: Configure Application Service
In IntelliJ Run Configuration:
| Field | Value |
|---|---|
| Name | AuthServiceApplication |
| Module | auth-service |
| Main Class | com.adventuretube.auth.AuthServiceApplication |
| Active profiles | mac |
| Environment variables | CONFIG_SERVER_URL=http://192.168.1.105:9297;ENV_TARGET=mac |
Environment Variables Explained
CONFIG_SERVER_URL=http://192.168.1.105:9297
- Points to where config-server is running
- Service fetches its
{service-name}.ymlfrom here
ENV_TARGET=mac
- Tells DotenvEnvironmentPostProcessor which env file to load
- Loads
env.macfor local development
Config Fetch Flow
Service Startup (e.g., auth-service)
│
↓
Spring Cloud Config Client Bootstrap
│
↓
HTTP GET: http://config-server:9297/auth-service/mac
│
↓
Config Server returns auth-service.yml content
│
↓
Merge with local application.yml
│
↓
Resolve ${PLACEHOLDERS} from env file
│
↓
Application Context Ready
│
↓
Register with Eureka
Config Server Endpoints
| Endpoint | Description |
|---|---|
GET /{service}/{profile} |
Fetch config for service and profile |
GET /auth-service/mac |
Auth service config for mac profile |
GET /auth-service/pi2 |
Auth service config for pi2 profile |
GET /actuator/health |
Health check |
Example Response
curl http://192.168.1.105:9297/auth-service/mac
Returns merged configuration from auth-service.yml
bootstrap.yml / application.yml
Services need to configure the config server location:
# bootstrap.yml or application.yml
spring:
application:
name: auth-service
cloud:
config:
uri: ${CONFIG_SERVER_URL:http://localhost:9297}
fail-fast: true
Startup Order Dependency
Critical: Config-server must be running before application services start!
Local (Manual)
1. eureka-server ← Start first
2. config-server ← Start second (registers with eureka)
3. auth-service ← Fetches config, then registers with eureka
4. member-service ← Fetches config, then registers with eureka
5. gateway-service ← Fetches config, then registers with eureka
Remote (Docker Compose – Automated)
depends_on:
config-service:
condition: service_healthy
Troubleshooting
Error: “Could not resolve placeholder”
- Config server not running
- Wrong CONFIG_SERVER_URL
- Service name mismatch
Error: “Connection refused to config server”
- Start config-server first
- Check port 9297 is accessible
Error: “Config not found for profile”
- Check
{service-name}.ymlexists in config folder - Verify profile name matches
Why ./mvnw spring-boot:run doesn’t work
Running from command line without environment variables fails:
./mvnw spring-boot:run -pl auth-service
# Error: Invalid URL: ${CONFIG_SERVER_URL}
# Error: No active profile set, falling back to default
Reason: Maven command doesn’t set:
ENV_TARGET– DotenvEnvironmentPostProcessor can’t load env.macCONFIG_SERVER_URL– Placeholder stays unresolvedSPRING_PROFILES_ACTIVE– Falls back to “default” profile
Solution: Use IntelliJ Run Configuration which sets these in Environment Variables field.
Important: Local development runs application services (auth, member, web, geospatial) via IntelliJ only. Cloud services (eureka, config, gateway) are deployed via Jenkins CI/CD.
Related Documents
- AdventureTube Cloud Services – Initialization & Build Process
Date: 2026-01-25
