How do you properly set different Spring profiles in bootstrap file (for Spring Boot to target different Cloud Config Servers)?

前端 未结 3 1914
天命终不由人
天命终不由人 2020-12-30 01:51

We have different config servers per environment. Each spring boot application should target its corresponding config server. I have tried to achieve this by setting profil

3条回答
  •  失恋的感觉
    2020-12-30 02:10

    Specifying different profiles in a single file is only support for YAML files and doesn't apply to property files. For property files specify an environment specific bootstrap-[profile].properties to override properties from the default bootstrap.properties.

    So in your case you would get 4 files bootstrap.properties, bootstrap-prod.properties, bootstrap-stage.properties and bootstrap-dev.properties.

    However instead of that you could also only provide the default bootstrap.properties and when starting the application override the property by passing a -Dspring.cloud.config.uri= to your application.

    java -jar .jar -Dspring.cloud.config.uri=
    

    This will take precedence over the default configured values.

提交回复
热议问题