Initialize spring bean profile through ContextLoaderListener in web.xml
11,027
You can configure web.xml
at the level of ContextLoaderListener
with:
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>profileName</param-value>
</context-param>
and the level of DispatcherServlet
with:
<init-param>
<param-name>spring.profiles.active</param-name>
<param-value>profileName</param-value>
</init-param>
Reference: http://spring.io/blog/2011/02/11/spring-framework-3-1-m1-released/
Author by
bachr
Updated on June 05, 2022Comments
-
bachr almost 2 years
In my
web.xml
I'm declaring aContextLoaderListener
to configure spring application this way:<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
In one of my spring configuration xml files, I'm using different beans profile for development and production.
<beans profile="production"> <bean /> </beans <beans profile="development"> <bean /> </beans
How I could set the default beans profile in the
web.xml
? is there something similar to the following when usingContextLoaderListener
instead of spring servlet:<init-param> <param-name>spring.profiles.active</param-name> <param-value>production</param-value> </init-param>