Spring Cloud Config Server Shared Properties Across Applications

前端 未结 3 1020
长发绾君心
长发绾君心 2021-01-02 03:08

I currently have a number of deployable applications that work in a distributed fashion to solve a business problem. We are currently using a number of property configuratio

相关标签:
3条回答
  • 2021-01-02 03:16

    I found working solution here https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html, paragraph "2.1.5 Sharing Configuration With All Applications". It says:

    With file-based (i.e. git, svn and native) repositories, resources with file names in application* are shared between all client applications (so application.properties, application.yml, application-*.properties etc.). You can use resources with these file names to configure global defaults and have them overridden by application-specific files as necessary.

    You should create application.properties or application.yml at the top level of configuration repository (if it is git or svn based). Don't forget to commit the changes.

    0 讨论(0)
  • 2021-01-02 03:20

    Finally found a solution. It's buried in the issues at github ...

    https://github.com/spring-cloud/spring-cloud-config/issues/32

    It worked liked described. I only noticed, that you need to put the files in a /config folder to make it work. If you put it in the root the file ist used by the configserver itself and is not included in the config requests.

    0 讨论(0)
  • 2021-01-02 03:28

    This is how I have configured for my setup.

    1 All Common properties across all services and environments will be in root->application.properties files

    2 All Common properties across all environments specific to service will be root->service-X.properties files

    3: Similarly, to have common properties across specific environment use env->application.properties file

    server:
      port: 8888
    spring:
      cloud:
        config:
          server:
            git:
              uri:[git repo]
              search-paths: /,/{profile}/
    

    0 讨论(0)
提交回复
热议问题