How to setup Spring Cloud Config Server Microservices

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.

--

--

--

Full Stack Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

August 4: Inside Cardstack This Week

Introducing: Dataframe SQL. Python or SQL? Why not both?

Open Source Series Intro

Different Techniques of FPGA Reverse Engineering using the bitstream.

Terraform Implementation framework for AWS

Deploy and use ArgoCD with Portainer (Part 1)

23 Web App Ideas to Check in 2021

How To Create Your First WordPress Widget

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
SABBAR El Mehdi

SABBAR El Mehdi

Full Stack Developer

More from Medium

Spring Cloud Config| Configuring Random Values in properties.

Creating a Java project using Maven archetype

Different ways to send mails from springboot application

Spring Boot Filter Example