2016-03-22 75 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}按預期工作。

相關問題