I am pretty new to spring boot, We are working on a spring boot application(packaging as a war file). When deploying this war file in higher environments on a tomcat server, 1. Can we configure the application.properties for diff environments inside the war (Be it dev, int, uat, prod)? OR 2. When application.properties is configured can we put that in a conf folder in tomcat, Outside the war file. (Similar to putting a context.xml in a traditional web application) and the app will still pick it up?
Yes, you can set different profiles for different environments. Let's assume we have dev, qa and prod environments. You need to create three files on same location where application.properties located with names like:
application-dev.properties for dev environmentapplication-qa.properties for qa environmentapplication-prod.properties for prod environmentNow, you just need to set spring.profiles.active=qa in application.properties. Currently, we set qa profile. You can set what you want.
Note The properties you set in new created profile will only available for active profile. For example, if you set some properties in dev file, it will only available only for dev environment. But properties set in application.properties will be available for all environment. So configurations which are not environment dependent can be placed in application.properties
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