Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring cloud config - loading additional files

I got a spring cloud server for my applications, serving the common property files at startup.

The 'normal' functionality is working fine. An application fetches the hierarchy of files and got the full access to the loaded parameters.

Application.properties
Application-<profile>.properties
<applicationname>.properties
...

Now the question: How can I load a configuration file beside the common naming?

If I am storing another file in repositoy e.g. sharedCommonServers.properties, how can I load this file in addition using the config server? This file contains properties used by some but not all programs.

Thank you in advance!

Hendrik

like image 397
Hendrik Jaenzoffski Avatar asked Jan 23 '17 13:01

Hendrik Jaenzoffski


1 Answers

Ok, at least I found a solution:

I took the normal application-context of cloud config. Within this context I placed my file sharedCommonServers.properties as a default application property file with a special profile.

Renaming:

'sharedCommonServers.properties' to 'application-commonServers.properties'

By extending the profile settings with 'commonServers' spring cloud config is fetching it in addition.

Take care there are no overlapping property-keys in the other profile-line.

So in my environment when I set...

-Dspring.profiles.active=prod,commonServers' 

...I get my default prod configuration and those marked as 'commonServers' profiles.

application.properties
application-prod.properties
application-commonServers.properties // the additional one
<appname>.properties
<appname>-prod.properties
// and <appname>-commonServers.properties if I would need it

Thank you for your suggestions and thoughts!

like image 163
Hendrik Jaenzoffski Avatar answered Sep 22 '22 13:09

Hendrik Jaenzoffski