spring.cloud.config.server.native.search-locations 不适用于 Spring Cloud Config 服务器中的占位符

Tom*_*lys 6 java spring spring-boot spring-cloud

我使用文件系统后端(spring.profiles.active=native)来加载配置文件。

我想要实现的是每个应用程序都有单独的文件夹,其中存储了适当组件的所有配置,例如 /configs/TestApp1/*.yml、/configs/TestApp2/*.yml

文档告诉这可以使用占位符{application}search-locations属性中完成(根据 Spring Cloud Config Server 文档http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_spring_cloud_config_server)。然而,这并不能解决问题。

我在配置服务器的 application.yml 中有以下配置

服务器:
  端口:8000

春天:
  云:
    配置:
      服务器:
        本国的:
          搜索位置:类路径:/configs/{application}

 简介:
    主动:本地

当我向端点发出 HTTP GET 请求时:http://localhost:8000/TestApp1/dev我没有从配置服务器获取配置,因为它没有将占位符替换为客户端应用程序名称(至少我认为它应该以这种方式工作) 并尝试查看以下目录:

未找到跳过的配置文件“classpath:/configs/{application}/TestApp1-dev.xml”资源
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/TestApp1-dev.xml”
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/TestApp1.xml”
未找到跳过的配置文件“classpath:/configs/{application}/TestApp1-dev.yml”资源
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/TestApp1-dev.yml”
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/TestApp1.yml”
未找到跳过的配置文件“classpath:/configs/{application}/TestApp1-dev.properties”资源
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/TestApp1-dev.properties”
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/TestApp1.properties”
未找到跳过的配置文件“classpath:/configs/{application}/TestApp1-dev.yaml”资源
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/TestApp1-dev.yaml”
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/TestApp1.yaml”
未找到跳过的配置文件“classpath:/configs/{application}/application-dev.xml”资源
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/application-dev.xml”
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/application.xml”
未找到跳过的配置文件“classpath:/configs/{application}/application-dev.yml”资源
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/application-dev.yml”
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/application.yml”
未找到跳过的配置文件“classpath:/configs/{application}/application-dev.properties”资源
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/application-dev.properties”
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/application.properties”
未找到跳过的配置文件“classpath:/configs/{application}/application-dev.yaml”资源
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/application-dev.yaml”
未找到配置文件开发资源的跳过配置文件“classpath:/configs/{application}/application.yaml”

注意:我尝试调试 Spring 源,但似乎在search-locations属性中没有替换占位符。好吧,我也有可能错过/误解了某些东西:)

也许有人可以建议我如何在 Spring Cloud Config Server 中为每个应用程序设置单独的配置目录?

Tom*_*lys 0

我使用 Spring Cloud Brixton.M5的里程碑版本进行了测试,搜索位置中的占位符 {application} 正常工作。