in the previous post sprig config server we have seen how to start a spring config server with a sample application config.
Let us see some more variations that spring allows us with spring config server.
The spring config server allows for using placeholders {application} and {profile} .
With this flexibility we can configure one repository per application against one repository for all the applications as we did in the previous post, let us see how. We will change what we did in earlier post so I will make changes to the same project to demonstrate the feature.
Let us first create two repositories for two applications “my-app-1” and “my-app-2”
Below I have created and initialized the first repo

add two files into this directory as application.yml and application-dev.yml
application.yml
app:
name: my-app-1
application-dev.yml
app:
name: my-app-1-dev
commit this file into the git repo with “git add .” and “git commit”

Now, similarity create another repo in the same root directory with name “my-app-2”, in my case it was “C:\Users\<user>\git”
So we have two repositories for the two apps now, one with name “my-app-1” and another with “my-app-2”. Now lets add this config to the server application config.
Navigate to the configuration of the config-server and update the git url to use application placeholder like below.
spring:
application:
name: my-config-server
cloud:
config:
server:
git:
uri: file://c://Users/<user>/git/{application}
Now lets start the config server and see the application in action
browse the url – http://localhost:8001/my-app-1/dev to view dev profile and http://localhost:8001/my-app-1/master to view the master or the default profile. Similarly you can use http://localhost:8001/my-app-2/dev or http://localhost:8001/my-app-2/master for the “my-app-2” config.
With the placeholder “{profile}” we can also create various other combinations. For e.g. we can create directories within the application repo for each of different profile instead of the suffix used in our example or in case of single repository for all the applications, we can use profile for dev and test or any folder of your choice within the repository.
You can also use the placeholder {application} or {profile} in searchpath config which basically is instruction to the spring config server on the whereabouts of your app config.
I have created two directories under the single repository configuration from my previous post and instead of having the config with the app name into the root directory, now I have created 2 directories for each app within the same root directory like below

I will have to also update the config-server application configuration to instruct on this new application locations.
spring:
application:
name: my-config-server
cloud:
config:
server:
git:
uri: file://c://Users/<user>/git/app-config
searchPaths: '{application}'
server:
port: 8001
Now restart the server and browse urls – “http://localhost:8001/my-app-1/master” or “http://localhost:8001/my-app-2/master” or their dev profiles. You should be able to see the change consistent with the expectations. Spring config server will now pull the configuration from the application directories.