I have a Config Server up and running, with the relevant application.yml setting of
spring:
application:
name: config
...
searchPaths:
- '{application}'
- '{application}/{profile}'
I would like to access a file that is not application.properties
, something like myfile.txt
. If I have the git layout
/myapp/nested/folder/myfile.txt
I want to be able to access that file. According to the Spring Config Server docs, I should be able to do this via /{name}/{profile}/{label}/{path}
, but I can't get any paths to work.
TL;DR: How do I retrieve nested config files from a git repo via Config Server?
TL;DR: The documentation is wrong. The endpoint /{name}/{profile}/{label}/{path}
should be written as /{application}/{profile}/{label}/{path}
. You just need to make sure that one of your searchPaths/{path}
can resolve your file.
First off, {label}
is, as always, the git branch name (probably "master").
Second, {path}
can can be an absolute path to the file. It uses /
, i.e., myapp/nested/folder/myfile.txt
, not (_)
as is required in {application}
or {label}
.
Third, the search paths in the question are set to '{application}'
and '{application}/{profile}'
, along with the default search path of /
, the git repo's root directory. These define the places Config Server will search for a plain text file as:
/{expanded application}/{path}
/{expanded application}/{profile}/{path}
/{path}
Note that only {application}
can be expanded into multiple folders with (_)
and that only {path}
can include multiple folders with /
. For instance, with these searchPaths
and a file located at /myapp/nested/folder/myfile.txt
, the following requests are valid:
/asdf/asdf/master/myapp/nested/folder/myfile.txt
/myapp/asdf/master/nested/folder/myfile.txt
/myapp/nested/master/folder/myfile.txt
/myapp(_)nested(_)folder/asdf/master/myfile.txt
/myapp(_)nested/folder/master/myfile.txt
where asdf
can be any arbitrary string.