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...) programmatically context.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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -