Centralized Configuration with Spring Cloud Config
Manage configuration for many microservices in one place using Spring Cloud Config Server and externalized property sources.
Centralized Configuration with Spring Cloud Config is a free Spring Boot 4 Complete Guide lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Spring Boot 4 Complete Guide learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Configuration Problem at Scale
With dozens of microservices, scattering properties across each one becomes unmanageable. Centralized configuration stores settings in one source that every service reads from.
What Is Spring Cloud Config?
Spring Cloud Config provides a Config Server that serves configuration to client services, typically backed by a Git repository for versioning and auditability.
Setting Up the Config Server
Annotate a Spring Boot app with @EnableConfigServer to turn it into a configuration hub.
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApp {
}Pointing to a Git Backend
Configure the server to read from a Git repo. Each service's properties live as files in that repo.
spring.cloud.config.server.git.uri=https://github.com/org/config-repoFile Naming Convention
Config files are named by application and profile, such as order-service-prod.yml. The server matches requests to the right file.
- application.yml — shared defaults
- order-service.yml — per service
- order-service-prod.yml — per profile
Making a Service a Config Client
A client service adds the config client starter and declares which application name and Config Server to use.
spring.application.name=order-service
spring.config.import=configserver:http://localhost:8888How Clients Fetch Config
On startup, the client contacts the Config Server, downloads its properties, and merges them into its environment before the rest of the app initializes.
Refreshing Without Restart
The @RefreshScope annotation lets beans pick up new values when you POST to the /actuator/refresh endpoint, avoiding full restarts.
@RefreshScope
@Component
public class FeatureFlags {
}Securing Sensitive Values
Secrets like passwords should be encrypted. The Config Server supports encrypting values so the Git repo never stores plaintext credentials.
Profiles and Environments
By using profile-specific files, the same service binary picks up dev, staging, or prod settings simply by activating the matching profile.
Why This Pattern Wins
Centralized, versioned, refreshable config means you change a setting once, audit who changed it, and roll it out without rebuilding services.
Quick Check
Test your understanding of centralized configuration.
Recap
You set up a Config Server backed by Git, connected client services, used profile-specific files, and enabled live refresh with @RefreshScope. Centralized config keeps a fleet of microservices consistent and manageable.
Frequently asked questions
Is the “Centralized Configuration with Spring Cloud Config” lesson free?
Yes — the full text of “Centralized Configuration with Spring Cloud Config” is free to read here on the web, and the Spring Boot 4 Complete Guide course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Spring Boot 4 Complete Guide course, upgrade to CoddyKit PRO.
What will I learn in “Centralized Configuration with Spring Cloud Config”?
Manage configuration for many microservices in one place using Spring Cloud Config Server and externalized property sources. You practise Spring Boot 4 Complete Guide with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Spring Boot 4 Complete Guide?
No prior experience is required. Spring Boot 4 Complete Guide on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Centralized Configuration with Spring Cloud Config” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Spring Boot 4 Complete Guide lesson?
Yes. Every Spring Boot 4 Complete Guide lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Microservices Principles & Design
- Service Discovery & Registration
- API Gateway with Spring Cloud Gateway
- Centralized Configuration with Spring Cloud Config