spring cloud config searchPaths

roy*_*ley 1 spring-boot spring-cloud

我正在考虑通过 Spring Cloud Config 实现 12factor 方法来外部化配置,但无法按预期使用 searchPaths 使通配符工作。

文档http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_spring_cloud_config_server提到可以在 searchPaths 变量中使用通配符 {application}、{label}、{profile},以便“您可以隔离路径中的目录,并选择对您有意义的策略(例如每个应用程序的子目录,或每个配置文件的子目录)。

我希望有一个 git repo,每个配置文件都有子目录(然后是每个应用程序,或者每个应用程序的子目录(然后是配置文件)。

例如

    spring:
      cloud:
        config:
          server:
            git:
              uri: https://stash.xxx.com.au/scm/xxx/config
              searchPaths: {application}
or
              searchPaths: {profile}
or
              searchPaths: {application}/{profile}
Run Code Online (Sandbox Code Playgroud)

但是,当我在搜索路径中使用任何通配符 {application} 或 {profile} 时,它在 git repo 中找不到数据,或者连接选项根本无法启动。

有没有人有我可以参考的工作示例?干杯罗伊

小智 8

使用单引号,它工作正常。

searchPaths: '{application}'
Run Code Online (Sandbox Code Playgroud)

如果有人偶然发现这个问题,希望这会有所帮助。


Dav*_*yer 1

实际上,用户指南中的示例都没有显示searchPaths. 我认为 GIT 后端不支持该功能(但{application}实际上是文件系统后端的默认功能,即在“本机”配置文件中工作的功能)。