Spring cloud config - download additional files

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

The "normal" functionality is working fine. The application retrieves the file hierarchy and gets full access to the downloaded parameters.

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

Now the question is: How to load the configuration file next to the common name?

If I store another file in the repository, for example. sharedCommonServers.properties, how can I download this file additionally using the configuration server? This file contains properties used by some, but not all, programs.

Thank you in advance!

Hendrick

+6
source share
1 answer

Well, at least I found a solution:

I took the usual application context for cloud configuration. In this context, I placed the sharedCommonServers.properties file in the default application properties file with a special profile.

Rename:

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

Extending profile settings with the 'commonServers' spring, the cloud configuration further extracts it.

Make sure that there are no overlapping property keys in the other profile line.

So, in my environment, when I installed ...

 -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 

Thanks for your suggestions and thoughts!

+4
source

Source: https://habr.com/ru/post/1014324/


All Articles