6
votes

I use File system backend (spring.profiles.active=native) to load configuration files.

What I want to achieve is to have separate folder per application where all the configuration of appropriate component is stored e.g. /configs/TestApp1/*.yml, /configs/TestApp2/*.yml

Documentation tells that this can be done using placeholder {application} in search-locations property (according to Spring Cloud Config Server documentation http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_spring_cloud_config_server). However this does not do the trick.

I have the following config in application.yml of configuration server

server:
  port: 8000

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

 profiles:
    active: native

When I make HTTP GET request to endpoint: http://localhost:8000/TestApp1/dev I do not get configuration from the Config Server as it does not replace placeholder to client application name (at least I think it should work in this way) and tries to look in the following directories:

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: I tried to debug Spring sources but it seems that placeholders are not replaced in search-locations property. Well, there is also a chance that I might have missed/misunderstood something :)

Maybe someone could advice how can I have separate configuration directory per application in Spring Cloud Config Server?

1
What version are you using? - spencergibb
I'm using Angel.SR4 (spring-cloud-parent - 1.0.3.RELEASE, spring-boot-starter-parent - 1.2.6.RELEASE) - Tomas Zuklys
I did a quick check with version Angel.SR6 (spring-cloud-parent - 1.0.4.RELEASE, spring-boot-starter-parent - 1.2.8.RELEASE) but still no luck to make it working. - Tomas Zuklys
This feature works as expected with Brixton.M5. - Tomas Zuklys
Yes, it's a new feature in Brixton. - spencergibb

1 Answers

0
votes

I did a test with milestone version of Spring Cloud Brixton.M5 and placeholder {application} in search-locations is working as expected.