问题
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