At the moment, all my properties are defined in the file src/main/resources/application.properties
. However, I would like to have properties files relating to different profiles in the src/main/resources/config
folder, and I want to be able to choose any of them. such as:
application-DEV.properties
application-TEST.properties
application-SERVER1.properties
So, the question is how to select these properties. If I was compiling to a jar
file, I could do that easily by specifiying the profile when running the jar
file, but here I just copy the generated war
file to a Tomcat webapps directory.
Well, I've found a way to do that. In the conf
directory of Tomcat, add this line to the file catalina.properties
there.
spring.profiles.active=<YOUR_PROFILE>
Replace <YOUR_PROFILE>
here of course with your profile's name. For example if you are using application-TEST.properties
, it would be the following.
spring.profiles.active=TEST
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With