I'm seeking solution for this problem.
I have several property files(application.properties, application-realdb.properties). Let's say I'm starting with "realdb" spring profile. Now I want to override my properties when deployed on tomcat. I decided to put the file to /lib folder as it is automatically on classpath and I didn't found any better(ie app specific classpath folder)
So I can place there application.properties, which will work so long as I will have only one application. In case I have multiple spring boot application I'd like to name the file(NOTE: application specific naming)
I can use app. specific spring profile and add /lib/application-appname.properies, which includes the necessity to pass the proper profile
I can use --spring.config.name, which I don't like as well for the need of passing it in command line(I'm not aware of possibility to do it in the war file, maybe set system property in spring boot main class?)
in @ConfigurationProperties(locations = "classpath:appname.properties, prefix..." it works as I want it is overriden properly, but only for the class I'm binding the values.
Sum up: Is there a way how to copy specificly named file on classpath and, thus override application.properties????
UPDATED Proposed solution works I can now use different properties name, but I still have problem with loading files in classpath outside.
Adding [applicationConfig: [classpath:/my-app-realdb.properties]] PropertySource with search precedence immediately lower than [applicationConfigurationProperties]
Adding [applicationConfig: [classpath:/config/my-app.properties]] PropertySource with search precedence immediately lower than [applicationConfig: [classpath:/my-app-realdb.properties]]
Adding [applicationConfig: [classpath:/my-app.properties]] PropertySource with search precedence immediately lower than [applicationConfig: [classpath:/config/my-app.properties]]
the last one is in .war, I quess the /lib/config folder should have precedence
3. A classpath /config package
4. The classpath root
So the hunt for answer is still on
UPDATE2 Looks like the order is
1. /config/application-<profile_specific>.properties
2. /application-<profile_specific>.properties
3. /config/application.properties
4. /application.properties
This means I cannot override, all with non-profile specific properties, which maybe is as intended, but for me, if I want just one file to rule them all not very useful.