How can I set the default environment in Spring Boot?
I put in application.properties
:
spring.profiles.include=prod,dev
spring.profiles.active=prod
and in user variables:
SPRING_PROFILES_ACTIVE = dev
So when I dev in my comp my environment are dev but when I generate my .war
and deploy in tomcat he still using dev
with enviroment (I deploy in another comp with no other conf)
How can I set my default environment (if he don't find any in user variables or commmand line uses production)?
What you need is:
1) Define the active profile you need, something like:
spring.profiles.active=dev
In this example the loaded file will be application-dev.properties
Now, if you need to switch to a different environment depending where are you installing your war file what you can do is to set this variable as a system variable in each environment you want, that way each environment has a different value for the same key, something like:
-Dspring.profiles.active=dev
In my case I am using Tomcat and I declare this key/value in the file setenv.sh
, you need to assign that value depending on the server you're using.
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