Search code examples
javaspring-bootspring-cloudspring-cloud-configspring-profiles

Different configurations for MicroService from Spring Configuration Server


I have a Spring Configuration Server Running as Microservice, On Stratup it loads the config file from the Git Repository according to the profile:

For Example foo profile loads application-foo.yaml from the configured Git Repository.

How i Run this Config Server Service with multiple profiles ? Then according to the Spring profile of the Spring Service Client (using the config server above) i could retrieve the right profile for my service instance.

For Example i can Run a service with bar as value for spring.active.profile the it will get the application-bar.yaml from the Git Repository ?

I have done some tests, and it seems the config server load only one Git Conf Repository, and no matter the spring active profile value used by my Service (targeting the Config Service ) it always loads the application-foo.yaml.

Thanks for your help.


Solution

  • I found the answer to my problem.

    Using Pattern Matching and Multiple Repositories by Official Spring Cloud Server Doc

    My Client call my server config by this request : serverurl/{application}/{profile} then it fetchs a pattern corresponding to the {profile} in this path spring > cloud > config > server once pattern matchs it load the right config files from the founded Git Repo.