Javatpoint Logo
Javatpoint Logo

Setting up Spring Cloud Config Server

Step 1: Create a Maven project using Spring Initializr https://start.spring.io/

Step 2: Choose the Spring Boot version 2.2.0 M6 or higher version. Do not choose the snapshot version.

Step 3: Provide the Group name. In our case, com.javatpoint.microservices.

Step 4: Provide the Artifact id. We have provided spring-cloud-config-server.

Setting up Spring Cloud Config Server

Step 5: Add the Spring Boot DevTools and Config Server dependencies.

Setting up Spring Cloud Config Server

Step 6: Click on Generate the project button. A zip file will download, extract it in the hard disk.

Step 7: Now, open the eclipse. Import the downloaded maven project. It will download the required files.

In the next step, we will create a simple Git repository and configure the spring cloud config server to pick up the values from the particular Git repository. We need to install the local Git.

Installing Git and creating a local repository

Step 1: Download Git from https://git-scm.com/ and install it.

Step 2: Create a Git repository and store the files that we want to be able to configure a limits-service. We will try to access them from the spring-cloud-config-server. Open the Git bash and type the following commands:

Creating a new directory:

Initializing a new Git repository:

It initializes an empty git repository.

Step 3: Now move to the spring-cloud-config-server project and add a link to the specific folder.

  1. Right-click on the spring-cloud-config-server project.
  2. Click on Build Path->Configure Build Path
  3. Select the Source tab.
  4. Click on Link Source and browse the folder git-localconfig-repo.
  5. Right click on the folder-> New -> Other -> File -> Next -> Provide the file name: limits-service-properties-> Finish.
  6. Now write the following code in the properties file:

Step 4: Configure the user name and user email:

The command commits any file we have added with the git add command and also commits any files we have changed since then.

Now execute the command to commit the changes in the repository. It records or snapshots the file permanently in the version history.

Setting up Spring Cloud Config Server

We can see that a file is changed with two new instructions. These instructions are changed in the local repository.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA