Spring Cloud Config Server

👉 A detailed guide to get hands-on expertise in developing, debugging and maintaining Cloud Config Servers.


What is config server ?

Spring Cloud Config Server is a centralized configuration management service which allows Spring Boot applications to externalize and retrieve configuration from a shared source, typically a Git repository, at runtime.

It solves the configuration consistency and management problems in distributed microservice systems.


Why config server exists ?

In a microservice architecture, configuration quickly becomes a systemic problem. Each service may run in multiple environments and require frequent, coordinated changes.

Spring Cloud Config Server exists to address following challenges:

  • Eliminates duplicated configuration across services
  • Enables environment-specific configuration without rebuilding services
  • Allows configuration changes without redeploying applications
  • Provides a single source of truth for runtime properties

Without a centralized config server, teams often rely on hard-coded values, environment variables, or manual synchronization—approaches that do not scale reliably.


When to use config server ?

The Spring cloud config server should be used when:

  • You operate multiple Spring Boot services.
  • Each service runs across multiple environments (dev, QA, prod).
  • Configuration values change more frequently than code.
  • You want auditability and version control for configuration.

It is not necessary for single-service or prototype applications with static configuration.


High-Level architecture

At an architectural level, Config Server acts as a read-only configuration provider for client services.

[Mermaid Diagram of Spring Cloud Config Server architecture with Git-backed configuration]

Flow summary:

  1. Configuration is stored in a Git repository
  2. Config Server reads configuration from Git
  3. Client services request configuration on startup
  4. Environment-specific properties are resolved automatically

This design keeps services stateless with respect to configuration.


App config repository structure

Spring Cloud Config Server uses a convention-based naming strategy to resolve configuration.

Configuration files are named using:

<application-name>[-<profile>].properties

This convention enables automatic environment resolution without custom logic.

Example structure

limits-service.properties
limits-service-dev.properties
limits-service-qa.properties
limits-service-prod.properties

currency-exchange-service.properties

Each file represents a logical configuration layer, not a deployment artifact.


Role of Config Server app ?

The Config Server application itself is a standard Spring Boot application with a single responsibility:

  • Expose configuration over HTTP
  • Fetch configuration from a backing repository
  • Serve environment-aware property sets to clients

It does not contain business logic and should remain lightweight.


Enabling config server capability

To act as a Config Server, the application must explicitly enable the server capability.

This is done by adding the Config Server dependency and enabling it at startup.

Maven dependency

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
</dependency>

This dependency provides all server-side infrastructure required for configuration serving.


Application config

The application is converted into a Config Server by enabling it explicitly.

@EnableConfigServer
@SpringBootApplication
public class CloudConfigServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(CloudConfigServerApplication.class, args);
    }
}

The annotation activates configuration endpoints and Git-backed resolution logic.

No additional bootstrapping is required.


Config server runtime configuration

The Config Server itself requires minimal configuration.

spring.application.name=b2-sboot-cloud-config-server
server.port=8888

spring.cloud.config.server.git.uri=https://github.com/SRVivek1/spring-cloud-config-server-git-repo.git

This configuration defines:

  • The identity of the Config Server
  • The port it listens on
  • The Git repository used as the configuration source

The Git URI can point to local, file-based, or remote repositories.


Supported git repository locations

Spring Cloud Config Server supports multiple Git-backed sources.

  • Local filesystem

    • file:///path/to/git/repo
  • Windows filesystem

    • file:///c:/path/to/git/repo
  • Remote Git repository

    • https://github.com/...

This flexibility allows teams to evolve from local setups to remote repositories seamlessly.


Key takeaways

  • Spring Cloud Config Server centralizes configuration management
  • Configuration is externalized, versioned, and environment-aware
  • Services remain configuration-agnostic and easier to operate
  • Git acts as the single source of truth

This component is typically the first Spring Cloud service introduced in a distributed system.


Project Reference:
→ Check the project POC on Github - Spring Cloud Config Server.


References