spring cloud config searchPaths [英] spring cloud config searchPaths

查看:92
本文介绍了spring cloud config searchPaths的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm looking at implementing the 12factor approach to externalising config via Spring Cloud Config but am not able to get the wildcards working using searchPaths as I expected.

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

The documentation http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_spring_cloud_config_server mentions that wildcards {application}, {label}, {profile} can be used within the searchPaths variable so that "you can segregate the directories in the path, and choose a strategy that makes sense for you (e.g. sub-directory per application, or sub-directory per profile)."

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

I'm looking to have a single git repo, with either subdirectories per profile (and then per app, or subdirectory per app (then by profile).

例如

    spring:
      cloud:
        config:
          server:
            git:
              uri: https://stash.xxx.com.au/scm/xxx/config
              searchPaths: {application}
or
              searchPaths: {profile}
or
              searchPaths: {application}/{profile}

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

However when I use any of the wildcards {application} or {profile} in my searchPaths it doesn't find the data in the git repo, or for the concatenated option fails to startup at all.

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

Does anyone have a working example of this I can refer to? Cheers Roy

推荐答案

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

Actually none of the examples in the user guide show the pattern being used in a list of searchPaths. I don't think that feature is supported with the GIT backend (but {application} is effectively the default in the filesystem backend, i.e. the one that works in the "native" profile).

这篇关于spring cloud config searchPaths的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆