Shared Config(at git) between SPring Boot Services

巧了我就是萌 提交于 2020-03-06 09:03:19

问题


I am developing spring boot services.

So lets say I have 3 Services A, B, C with dev and prod profiles each. Now I am keeping the configuration for these services at GIT and using config server to fetch the configuration.

So when I run A service in prod mode, the config file A-prod.properties is getting used.

Now I want to keep some common configuration which will be used by all 3 Services say common-prod.properties. How should I do that?

I have tried this:

Config Server :

spring:
  cloud:
    config:
      server:
        git:
          uri: http://gitPaath/Configs.git
          username: <username>
          password: <pass>
          cloneOnStart: true
          searchPaths: "{common}"

My properties are file are in Git Repo in this order :

- A-prod.properties
- A-dev.properties
- B-prod.properties
- A-dev.properties
- C-prod.properties
- C-dev.properties
- common
   - common-prod.propeties
   - common-dev.properties

回答1:


You can put all shared properties between services in application-<profile>.properties file.

In your case, make application-prod.properties and application-dev.properties files and put these file on root folder or any folder that is searchable by config server.

You can find more details in "Sharing Configuration With All Applications" section in here.



来源:https://stackoverflow.com/questions/45499251/shared-configat-git-between-spring-boot-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!