I have following Spring cloud config application.yml:
spring:
application:
name: configserver
cloud:
config:
server:
git:
uri: https://[email protected]/xyz/microservices-configs.git
username: xyz
password: xyz
basedir: target/configs
server:
port: 8881
Following is my bootstrap.yml
of user microservice:
spring:
application:
name: userservice
cloud:
config:
uri: http://localhost:8881/
Scenario - 1
When I hit config server in browser like this:
http://localhost:8881/development/userservice-development.yml
It serves file properly. and when I look at basedir
i.e. target/config, I see:
- userservice.yml
- gateway.yml
Exactly what I wanted, Since I added this two files only in development branch.
Scenario - 2
When I run my userservice microservice project using following command:
mvn clean spring-boot:run -Dspring.profiles.active=development
It fetches the right file from git, but it checkout from master branch ! but not from the development branch as I am expecting. am I expecting right ? (FYI I have both development and production yml in master branch)
So the question is, how do we go for using config server ? Is there any configuration which we can set to fetch yml from that particular branch only ? I believe we need to set some label, because as per documentation, default label is master. Can anyone let me know how do we go for setting label in above scenario ?
According to the documentation, the configuration you want to set in your config client is:
spring.cloud.config.label=mybranch
Where mybranch
is an existing branch in your git repo.