use*_*027 7 java microservices spring-cloud-config
我想尝试spring cloud config微服务项目,我有一个common config所有服务和multiple configs每个服务.
我知道如何使用多个profiles使用spring.profiles.active和include.我试图了解如何在配置客户端上加载多个配置?
在我的git repo中,我有spring-config-repo我所拥有的......
application.yml
orderclient.yml
subscriberclient.yml
jmsclient.yml
productclient.yml
Run Code Online (Sandbox Code Playgroud)
我config Server指向我的配置仓库.
spring:
application:
name: config-service
cloud:
config:
server:
git:
uri: https://github.com/<user>/spring-config-repo
server:
port: 8888
Run Code Online (Sandbox Code Playgroud)
我有我spring client想要使用多个配置的地方.在我的情况下orderService我想加载application.yml,orderclient.yml,jmsconfig.yml和For Product microService我需要'orderconfig.yml,jmsclient.yml,productclient.yml'
spring:
application:
name: orderclient
profiles:
active: test
cloud:
config:
uri: http://localhost:8888
###Any kind of config properties to load jmsclient, productclient?
Run Code Online (Sandbox Code Playgroud)
上面我可以从orderclient.yml访问属性.
如何访问的性质jmsclient.yml,productclient.yml的orderclient应用.
无论如何得到propertySources.name配置服务器暴露的所有列表?在上述情况下它应该显示出来
"propertySources": {
"name": "https://github.com/<>/spring-config-repo/aplication.yml",
"profiles": <available profiles for this say> Dev, Test,
"name": "https://github.com/<>/spring-config-repo/orderclient.yml",
"profiles": <available profiles for this say> Dev, Test
"name": "https://github.com/<>/spring-config-repo/jmsclient.yml",
"profiles": <available profiles for this say> Dev, Test
....}
Run Code Online (Sandbox Code Playgroud)
如果我的问题不明确或需要更多信息,请告诉我.谢谢.
pom*_*ine 12
您可以使用spring.cloud.config.name属性设置要加载的逗号分隔的配置列表:
spring.cloud.config.name: jmsclient,productclient,orderclient
Run Code Online (Sandbox Code Playgroud)