Spring boot config server
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Spring Cloud Config Server centralizes configuration for multiple services. Instead of baking environment-specific values into each application, you keep configuration in a shared backend such as Git and let services fetch it at startup.
This is useful in microservice systems where many applications need coordinated settings, profile-specific overrides, and a clear history of configuration changes. It also separates application code changes from operational config changes.
What the Config Server Does
Config Server is a normal Spring Boot application with the config server dependency enabled. It reads configuration from a backend repository and serves it over HTTP using conventions like /application/default or /orders-service/prod.
A Git-backed repository is the most common setup because it gives you version control, reviewable pull requests, and rollback history.
Build the Server
A minimal Maven setup needs Spring Boot and the Spring Cloud Config Server starter.
Enable the server in your main class:
Configure the Git backend in application.yml:
When the server starts, it can serve files such as orders-service.yml, orders-service-prod.yml, or application.yml from that repository.
Configure a Client Service
A client service points to the config server and imports its configuration during startup.
When orders-service starts with the prod profile, it asks the config server for the merged configuration of orders-service and the shared application files.
Refreshing Configuration
Config values are usually loaded at startup, but some applications need runtime refresh. With Spring Actuator and @RefreshScope, a bean can reload values when the refresh endpoint is triggered.
This is useful, but do not overuse live refresh for every property. Some changes are safer with a controlled restart.
Secure the Configuration Path
Because config servers often distribute database credentials, API keys, and service endpoints, they must be protected. Use HTTPS, require authentication, and restrict network access. If you store secrets in Git, use encryption support or move secrets into a dedicated secret manager such as Vault.
Centralization improves manageability, but it also creates a high-value target. Treat the server and its backend repository as production-critical infrastructure.
Common Pitfalls
- Putting secrets in plain text without access controls. A central config system magnifies the impact of weak secret handling.
- Forgetting the client
spring.application.name. Without it, the server cannot resolve the correct application-specific file set. - Assuming every property change can be refreshed safely at runtime. Some beans still need a restart.
- Running config server without strong availability planning. If clients depend on it at startup, outages can cascade.
- Mixing code and environment overrides inconsistently. A central config system only helps when teams use it predictably.
Summary
- Spring Cloud Config Server centralizes external configuration for many services.
- A Git backend is common because it provides history, review, and rollback.
- Clients fetch config based on application name and active profile.
- '
@RefreshScopecan reload selected values, but not every change should be live-refreshed.' - Secure the server carefully because it often distributes sensitive operational data.
Related reading
- Spring Boot containers can not connect to the Kafka container
- Spring Boot custom Kubernetes readiness probe
- Spring Boot in Docker
- Spring Boot integration tests AutoConfigureMockMvc and context caching
- Spring Boot Configuration Class is simply ignored and not loaded
- Spring Boot configure and use two data sources
- Spring Boot JPA2 Hibernate - enable second level cache
- Spring Boot Multiple similar ConfigurationProperties with different Prefixes

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.