简体   繁体   English

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

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

What I want to try: 我想尝试一下:

I want to try the spring cloud config for microservice project where I have a common config for all services and multiple configs for each service. 我想尝试针对微服务项目的spring cloud config ,其中我为每个服务提供了所有服务和multiple configscommon config
I got idea on how to use multiple profiles using spring.profiles.active and include . 我知道如何使用spring.profiles.activeinclude来使用多个profiles I am trying to understand how can I load multiple configs on config client? 我试图了解如何在配置客户端上加载多个配置?

What I have: 是)我有的:

In my git repo I have spring-config-repo where I have ... 在我的git repo中,我有spring-config-repo ,我有......

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

I have my config Server pointed to my config repo. 我的config Server指向我的配置仓库。

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

server:
 port: 8888

I have my spring client where I want to use multiple configs. 我有我的spring client ,我想使用多个配置。 Here in my case for orderService I want to load application.yml,orderclient.yml,jmsconfig.yml and For Product microService I need 'orderconfig.yml,jmsclient.yml,productclient.yml' 在我的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?

Above I can access properties from orderclient.yml. 上面我可以从orderclient.yml访问属性。

My Question: 我的问题:

Question1: 问题1:

How to access properties of jmsclient.yml,productclient.yml in orderclient application. 如何在orderclient应用程序中访问jmsclient.yml,productclient.ymlorderclient

Question2: 问题2:

Is there anyway to get list of all propertySources.name exposed by config server? 反正有没有得到配置服务器公开的所有propertySources.name列表? where in above case it should dispaly 在上述情况下,它应该显示出来

"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
 ....}

Please let me know if my question is not clear or need more information. 如果我的问题不明确或需要更多信息,请告诉我。 Thanks. 谢谢。

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

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

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

相关问题 如何使用带有 postgresql 和 jdbc 的 Spring Cloud 配置服务器作为具有多个配置文件的后端? - How to use spring cloud config server with postgresql and jdbc as backend with multiple profiles? 如何将Spring Cloud Config与Git and Vault复合环境存储库一起使用? - How to use Spring Cloud Config with a Git and Vault composite environment repository? Spring 云配置服务器后备多个存储库 - Spring Cloud Config Server fallback for multiple repositories 使用 Spring Cloud Config 进行配置 - Config with Spring Cloud Config 为什么一个消费者为 Spring Cloud Stream Kafka 创建多个消费者配置? - Why does one consumer create multiple consumer configs for Spring Cloud Stream Kafka? 在 Spring Cloud Config 服务器中包含多个应用程序的通用配置 - Include common config for multiple apps in Spring Cloud Config server 如何在带有Spring配置文件的Bean中使用多个通用属性? - How to use multiple common properties in a bean with a Spring config file? 如何在Spring Cloud Zuul中配置路由 - How to config routes in Spring Cloud Zuul 如何在 Spring Cloud Config 中定义共享数据源 - How to define a Shared DataSource in Spring Cloud Config 是否可以使用 Spring Cloud Config 将复杂的配置传递给 Spring Cloud 流函数 - Is it possible to use Spring Cloud Config to pass complex config to a spring cloud stream function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM