Spring Cloud Config - Multiple Composite Repositories?

烂漫一生 提交于 2019-12-08 07:12:47

问题


Is it possible configure Spring Cloud Config with multiple composite repositories? Our setup uses multiple team-based repositories:

spring:
  cloud:
    config:
      server:
        git:
          repos:
            teamA:
              cloneOnStart: true
              pattern: teama-*
              searchPaths: '{profile}'
              uri: file:///etc/config/teama
            teamB:
              cloneOnStart: true
              pattern: teamb-*
              searchPaths: '{profile}'
              uri: file:///etc/config/teamb 

We want each team to now pull from 2 different git repositories. I think multiple Composite repositories (https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html#composite-environment-repositories) is what we want, but I can't figure out how to combine them, or if it is even possible.

Clarification:

I want each team to pull configuration data from two repos instead of just the 1. In pseudo code:

spring:
  cloud:
    config:
      server:
        git:
          repos:
            teamA:
              repo1:
                key1: repo1
                key2: repo1
              repo2:
                key1: repo2
                key2: repo2

回答1:


In this case your can use composite configuration. Next configuration is working for me, client service is using properties from 2 repositories

spring:
  profiles:
    active: composite
  cloud:
    config:
      server:
        composite:
        -
          type: git
          cloneOnStart: true
          uri: https://github.com/..../test-config
        -
          type: git
          cloneOnStart: true
          uri: https://github.com/..../test-config-2

You may need to configure 'searchPaths' for each for your needs. Profile should be composite (at least one of profiles)



来源:https://stackoverflow.com/questions/51737545/spring-cloud-config-multiple-composite-repositories

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