繁体   English   中英

spring cloud config:如何使用多个配置

[英]spring cloud config : how to use multiple configs

我想尝试一下:

我想尝试针对微服务项目的spring cloud config ,其中我为每个服务提供了所有服务和multiple configscommon config
我知道如何使用spring.profiles.activeinclude来使用多个profiles 我试图了解如何在配置客户端上加载多个配置?

是)我有的:

在我的git repo中,我有spring-config-repo ,我有......

application.yml
orderclient.yml
subscriberclient.yml
jmsclient.yml
productclient.yml

我的config Server指向我的配置仓库。

spring:
  application:
  name: config-service
  cloud:
   config:
    server:
      git:
        uri: https://github.com/<user>/spring-config-repo

server:
 port: 8888

我有我的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?

上面我可以从orderclient.yml访问属性。

我的问题:

问题1:

如何在orderclient应用程序中访问jmsclient.yml,productclient.ymlorderclient

问题2:

反正有没有得到配置服务器公开的所有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
 ....}

如果我的问题不明确或需要更多信息,请告诉我。 谢谢。

您可以使用spring.cloud.config.name属性设置要加载的逗号分隔的配置列表:

spring.cloud.config.name: jmsclient,productclient,orderclient

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM