java - How to set the Profile using application.properties in Spring? -
i set profile using application.properties file entry:
mode=master
how set spring.profiles.active in context.xml file? init-param works in web.xml context.
<init-param> <param-name>spring.profiles.active</param-name> <param-value>"${mode}"</param-value> </init-param>
there few ways change active profiles, none of take directly properties file.
- you can use
<init-param>
doing in question. - you can provide system parameter @ application startup
-dspring.profiles.active="master"
- you can
configurableenvironment
applicationcontext
,setactiveprofiles(string...)
programmaticallycontext.getenvironment().setactiveprofiles("container");
you can use applicationlistener
listen context initialization. explanations on how here. can use contextstartedevent
contextstartedevent event = ...; // method argument configurableenvironment env = (configurableenvironment) event.getapplicationcontext().getenvironment(); env.setactiveprofiles("master");
you can value "master"
properties file see fit.
Comments
Post a Comment