首页 文章

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

提问于
浏览
2

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

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

文档告诉您可以使用 search-locations 属性中的占位符 来完成此操作(根据Spring Cloud Config Server文档http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_spring_cloud_config_server) . 然而,这并不成功 .

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

server:
  port: 8000

spring:
  cloud:
    config:
      server:
        native:
          search-locations: classpath:/configs/{application}

 profiles:
    active: native

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

Skipped config file 'classpath:/configs/{application}/TestApp1-dev.xml' resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1-dev.xml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1.xml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1-dev.yml' resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1-dev.yml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1.yml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1-dev.properties' resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1-dev.properties' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1.properties' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1-dev.yaml' resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1-dev.yaml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/TestApp1.yaml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/application-dev.xml' resource not found
Skipped config file 'classpath:/configs/{application}/application-dev.xml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/application.xml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/application-dev.yml' resource not found
Skipped config file 'classpath:/configs/{application}/application-dev.yml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/application.yml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/application-dev.properties' resource not found
Skipped config file 'classpath:/configs/{application}/application-dev.properties' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/application.properties' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/application-dev.yaml' resource not found
Skipped config file 'classpath:/configs/{application}/application-dev.yaml' for profile dev resource not found
Skipped config file 'classpath:/configs/{application}/application.yaml' for profile dev resource not found

Note: 我试图调试Spring源代码,但似乎在 search-locations 属性中没有替换占位符 . 好吧,我也有可能错过/误解了一些东西:)

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

1 回答

  • 0

    我使用里程碑版的Spring Cloud Brixton.M5 进行了测试,搜索位置的占位符正在按预期工作 .

相关问题