I want my default active profile to be production
if -Dspring.profiles.active
is not set.
I tried the following in my application.pro
Currently using Maven + Spring Boot. Our solution was the following:
application.properties
#spring.profiles.active= # comment_out or remove
securityConfig.java
@Value(${spring.profiles.active:[default_profile_name]}")
private String ACTIVE_PROFILE_NAME;
Credit starts with MartinMlima. Similar answer provided here:
How do you get current active/default Environment profile programmatically in Spring?
you can also have multiple listings in the @Profile annotation
@Profile({"dev","default"})
If you set "default" as an additional value, you don't have to specify spring.profiles.active