Home > AI > Backend > SpringBoot >

Use Spring-Cloud-Config for consolidating configuration files across microservices.


I’ve successfully completed the OAuth2.0 connection, imported 20 PTE questions, and conducted data-level testing. My next step is to proceed with REST APIs testing. However, before diving into that phase, I’m planning to deploy the SpringBoot application to the VPS server to ensure there are no compatibility issues.

We maintain four copies of configuration files for each microservice: a general version that specifies the profile to use, a local version for the local environment, a test version for VPS server testing, and a production version.

While working across multiple microservices, I’ve noticed that some configurations, like SSL settings in the local environment, remain identical across all services. I’m seeking ways to efficiently manage and edit these configurations centrally, rather than making separate modifications for each microservice.

In my exploration, I discovered that Spring-Cloud-Config offers a solution for this issue. I even watched a YouTube video to gain more insights. Here’s a screenshot from that video illustrating the updated workflow.

Github repository: https://github.com/tutehub/sample-spring/tree/develop/config

Step 1: Create config server

1-1) Create a project or module

1-2) Include dependency

<dependency>
    <groupId>org.springframework.cloud</groupId>  
    <artifactId>spring-cloud-config-server</artifactId>
    <version>4.0.3</version>
</dependency>

1-3) Add @EnableConfigServer by the @SpringBootApplication

1-4) add this to the application.properties

spring.cloud.config.server.git.uri=${HOME}/documents/work-web-nginx/PTE-SpringBoot-Config

Step 2: Create config client

Relevant tags:

Leave a Reply