The spring-boot project to demonstrate Spring cloud config server by accesing the configuration from a git repo config-repo
run mvn clean install
- [optional] To check the service getting registered with service discovery, we need to run the service discovery on our machine, You can find project in my repo eureka-service-discovery
- Step 1: Launch the service discovery
- Step 2: Update spring.cloud.config.server.git.uri property in properties file/yaml to the git/svn repo from which you want to access the configuration properties (sample: spring.cloud.config.server.git.uri=https://github.com/santhoshvernekar/config-repo.git)
- Step 3: Launch the config-server application
- Step 4: Spring-cloud-config server provides REST based feature to access the configuration,
The request should be in the format of: config-server-URL/app-name/profile/{label}
- app-name: The name of the application (Mandatory)
- profile: The spring-profile set while defining the configuration ex: prod,dev,default, by default we can mention value as "default" (Mandatory)
- label: An Optional parameter to specify the different labels defined
We can get the configurations in the desired format (Supported formats: json/yaml/properties )
For Example: Config server is running on localhost 8888 port, so we can retrieve the configurations with below requests
- http://localhost:8888/config-server/prod
- http://localhost:8888/config-server.prod.properties
- http://localhost:8888/config-server.dev.yaml
- http://localhost:8888/config-server/default
Happy Coding!!
For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- Eureka Discovery Client
- Spring Boot Actuator
- Spring Web
The following guides illustrate how to use some features concretely: