Search code examples
javaspringspring-bootmicroservicesspring-cloud

What does the property spring.cloud.config.label in Spring Cloud config do?


I am learning Spring Cloud Config v3.0.5. When I was studying in the documentation, I found that the documentation mentioned that

For instance, you might want to align the config label with your branch but make it optional (in that case, use spring.cloud.config.label=myfeature,develop).

I don’t know what “align the config label” means. But I guess it should be to modify the default value of {label} in the url (the default value is master) enter image description here

However, when i set spring.cloud.config.label=dev and visit http://localhost:3344/config-dev.yml, i still get the data on master branch. enter image description here

enter image description here

So what does the property spring.cloud.config.label do? And what does "align the config label with your branch" mentioned in the document mean?


Solution

  • The property spring.cloud.config.label can be used in the client application, not in the config server.

    I assume that you use a git backend for your config server. To get a config that has the label dev, you need to create a branch or tag in the git repository that contains the config. The mechanism for other backends can be looked up in the reference documentation.

    After creating the branch, the URLs should work as expected. But please note that the URL http://localhost:3344/config-dev.yml refers to an application called config and a profile (not a label) dev. The default profile of a Spring application is default and one of many ways to set it on a client is with the property spring.profiles.active.

    I agree that the word align in the reference documentation is unclear. I think they suggest to create branches in the config repository for feature branch development and use the same branch name for both the config and the code repository, respectively. Then you can set the label to the branch name in the feature branch of the client's code repository.