by BehindJava

How to configure Spring Cloud Config Server using Spring Boot in Microservices

Home » microservices » How to configure Spring Cloud Config Server using Spring Boot in Microservices

In this tutorial we are going to learn about Spring Cloud Config Server Configuration using Spring Boot.

Firstly, we need to generate as Spring application using Spring Initializr and add the following dependencies as shown below.

cnff

Once the project is generated. It is download as a ZIP file, UNZIP the project and import in your Spring Tool Suite.

So, to make our Spring Boot application work as a Spring Cloud Config Server, we need add an annotation called @EnableConfigServer in the main class as shown below.

Code Snippet:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication
@EnableConfigServer
public class SpringcloudconfigserverApplication {

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

}

Now we need to add few configurations under src/main/resources in the application.properties as shown below.

Code Snippet:

spring.application.name=Springcloudconfigserver
server.port=8012

Our Spring Cloud Config Server has been configured succesfully to check this run your spring boot application spring tool suite and check the console for log whether the application is running on the configured port i.e., 8012 .