Looking for best approach in configuring multiple Profile specific property files in Springboot application. Below is an example:
-resources
-- application.properties
-- dev
-- application-dev.properties
-- ldap-dev.properties
-- quartz-dev.properties
-- etc-dev.properties
-- test
-- application-test.properties
-- ldap-test.properties
-- quartz-test.properties
-- etc-test.properties
-- prod
-- application-prod.properties
-- ldap-prod.properties
-- quartz-prod.properties
-- etc-prod.properties
The application.properties and application-profile.properties files are loading okay. I'm looking for a recommended approach in loading the other profile specific property files. I'm not sure if there is a way to load all property files from a folder based on a profile?
I'm not sure is there any better way to that or is my suggestion really work but you can try this:
Add
@PropertySource
Annotation right before your configuration classTo understand better how Spring load configurations from different sources and profiles see this and this.
I hope it helps.