How to setup Spring Cloud Config Server Microservices

SABBAR El Mehdi
2 min readJul 15, 2021

--

The Config server API is a central place to manage external properties for applications across all environments. In this article, I will include two ways.

Step 1:

Go to https://start.spring.io/ write a name for project(it’s preferable to be something significant, in my case it’s ApiConfigServer).
Add Config Server to dependencies, check that the Java version is match your local version!
That’s all what you need for now, click generate to download the .zip file and open it in IDE.

Step 2:

In application main class, add @EnableConfigServer

@EnableConfigServer
@SpringBootApplication
public class ApiConfigServerApplication {

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

In application.properties add the name and the port, for the name it should match project name.

Step 3:

To centralize configurations, there are two ways:
The first way: is by creating a private Github repository and push .properties files to it.

After doing that, you need to add this lines in application.properties of ApiConfigurationServer,
so it can fetch configurations from this remote repository.

The second way: is creating a folder in your computer, call it “dev” for example, then add.properties files into it.
To provide the project to localize the folder add the following lines to application.properties of your project

To tall the project to take in priority the local configurations, we should add the following properties.

I hope this article was helpful, if you have a question you can write it in comment, I will be happy to respond to it.

--

--