11

I'm trying to organise a set of config files in folders within my Git repo. I read in the Spring Cloud Docs this can be done this way:

The HTTP service has resources in the form:

/{application}/{profile}[/{label}] 

/{application}-{profile}.yml

/{label}/{application}-{profile}.yml

/{application}-{profile}.properties

/{label}/{application}-{profile}.properties

So I created my config structure following the first pattern:

app1/uat/application.yml

But the Config service doesn't find it. It doesn't really say much about what the files inside the profile folder should look like, and everywhere I see examples of the 2nd and 4th patterns.

Does the first pattern actually work? Can anybody give an example?

Community
  • 1
  • 1
Amin Abu-Taleb
  • 4,065
  • 5
  • 28
  • 48

1 Answers1

24

Solved, just needed to add:

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/your-repo
          searchPaths: '{application}/{profile}'

That will do the trick

Amin Abu-Taleb
  • 4,065
  • 5
  • 28
  • 48
  • 1
    Thanks a lot, it worked for me! Just one funny thing, I have a profile named dev and it just didn't work for it, I had to rename it to development and then the folder was mapped correctly... – Toyo Nov 24 '17 at 22:26
  • 1
    May not be immediately obvious, but multiple searchPaths are allowed. So just using the yaml list syntax works. The functionality seems to come from `ConfigFileApplicationListener`, though I found that contrary to stated in its documentation, precedence is decided in reverse: last location in the list wins. – Anly Jun 20 '19 at 16:04