Spring Boot - Cloud Configuration Server
Last Updated :
24 Apr, 2025
In microservices, we have several different services responsible for different functionalities. These services act like smaller application modules, which together form the application. Each of these modules has its own responsibility, based on the business logic of the application being built. These services then perform the CRUD (Create, Retrieve, Update, Delete) operations over the respective databases.
The process of developing our application takes place across different environments. Initially, the application is developed in the staging/development environments and then the application's codebase is gradually promoted to higher environments, that is the User Acceptance Test (UAT) environment and finally the Production Environment.
The objective for having different environments is to ensure our application code adheres to the specific standards as per the business requirements and is defect-free before it goes live and is used by the respective end users.
Hence, to achieve this we need to configure our application with certain properties specific to the respective environments.
Prerequisites for the Topic
- Project: Maven
- Language: Java
- Java Version: 11
- Packaging: Java Archive
- IDE: Eclipse (with Spring Tool Suite installed)
- Database: MySQL (with MySQL workbench)
Example
We may use different databases for different environments. That is, a different database for the development/staging environment and a different one for the Production environment.
Hence, for this purpose, our database server connection string as well as the credentials to connect to the given database would differ from environment to environment. Similarly, there may be certain other properties too, that would differ from one environment to the other environment.
Hence at any given time, there is a need to set up our application to be executed in different modes. These modes are called as your application profiles.
Managing the application across different profiles
In microservices architectural style, we have several different services. Each of these services act as smaller modules of our huge application.
Configuring individual property files specific to the respective environments in our individual services makes our application tightly coupled. Rather, this responsibility is handed over to a single micro service. This single micro service is referred to as the Spring Boot Cloud's Configuration Server.
The property files for all our services are placed inside this Spring Boot Cloud Configuration Server.
Set up and demonstrate the use of the Spring Boot Cloud Configuration Server
In this example, we shall consider a banking application being built. This application has a micro service called as the loans service. This service is responsible for issuing loans to the respective customers. These loan details of the customers are stored in a database. The databases used here, will differ from one environment to another environment. These database configuration property files will be stored in the classpath of the project.The property files for the loans service application in the System Integration Test (SIT), User Acceptance Test (UAT) and the default environment will be named as, loans-sit.properties, loans-uat.properties and loans.properties respectively.
The Spring Boot Projects are created using the Spring Starter Project utility.
- Create the Configuration Server Spring Boot Project in Eclipse IDE by going to,
File -> New -> Spring Starter Project - This will open the Spring Starter Project dialogue box below.
- Enter the project metadata details, giving any name to your project that you choose and click on Next.

Select the two dependencies below to be added to your project and click on Next:
- Spring Boot DevTools
- Config Server

Click on Finish.

Now we have created the Configuration Server project. In the same way, let us create the Loans service project.
- Create the Loans service Spring Boot Project in Eclipse IDE by going to,
File -> New -> Spring Starter Project - This will open the Spring Starter Project dialogue box below.
- Enter the project metadata details, giving any name to your project that you choose and click on Next.

Select the 5 dependencies below to be added to your project and click on Next:
- Spring Boot DevTools
- Config Client
- Spring Data JPA
- MySQL Driver
- Spring Web

Click on Finish.

Finally, we have the following Maven Dependencies added in the pom.xml file.
Spring Boot DevTools dependency
Config Server dependency
Config Client dependency
Spring Data JPA dependency
MySQL Driver dependency
Spring Web dependency
Setting Up the Configuration Server:
Java
//Java code implementation for setting Up the Configuration Server
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer
public class Gitconfigserver2Application {
public static void main(String[] args) {
SpringApplication.run(Gitconfigserver2Application.class, args);
}
}