Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Springboot - multiple property files per profile

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?

like image 613
Gary Avatar asked Nov 18 '14 20:11

Gary


1 Answers

You have quite a lot of flexibility with the built in configuration listener. E.g. You could set spring.config.name=application,ldap,quartz,etc and spring.config.location=classpath:/,classpath:/dev,classpath:/prod,classpath:/test. Or the equivalent env vars. The links in Selim's answer document the basic behaviour and config options.

like image 171
Dave Syer Avatar answered Sep 18 '22 09:09

Dave Syer