2016-03-22 76 views
1

我使用文件系统后端(spring.profiles.active = native)加载配置文件。spring.cloud.config.server.native.search-locations在Spring Cloud Config服务器中无法使用占位符

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

文档告诉,这可以使用搜索地点占位{}应用属性来完成(根据春季云配置服务器文档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 

的当我做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 

注:我试着调试春源但似乎占位符在搜索位置财产不被替换。那么,也有可能我错过/误解了某些东西:)

也许有人可以建议我怎么能在Spring Cloud Config Server中为每个应用程序分别配置目录?

+0

你使用的是什么版本? – spencergibb

+0

我使用Angel.SR4(spring-cloud-parent-1.0.3.RELEASE,spring-boot-starter-parent-1.2.6.RELEASE) –

+0

我用Angel.SR6(spring-cloud -parent - 1.0.4.RELEASE,spring-boot-starter-parent - 1.2.8.RELEASE),但仍然没有运气让它工作。 –

回答

0

我对Spring Cloud的里程碑版本进行了测试Brixton.M5和搜索位置中的占位符{application}按预期工作。

相关问题