[英]Initialize spring bean profile through ContextLoaderListener in web.xml
In my web.xml
I'm declaring a ContextLoaderListener
to configure spring application this way: 在我的
web.xml
我正在声明一个ContextLoaderListener
来以这种方式配置spring应用程序:
<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. 在我的一个spring配置xml文件中,我使用不同的bean配置文件进行开发和生产。
<beans profile="production">
<bean />
</beans
<beans profile="development">
<bean />
</beans
How I could set the default beans profile in the web.xml
? 我如何在
web.xml
设置默认的bean配置文件? is there something similar to the following when using ContextLoaderListener
instead of spring servlet: 使用
ContextLoaderListener
而不是spring servlet时,有类似的内容:
<init-param>
<param-name>spring.profiles.active</param-name>
<param-value>production</param-value>
</init-param>
You can configure web.xml
at the level of ContextLoaderListener
with: 您可以在
ContextLoaderListener
级别配置web.xml
:
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>profileName</param-value>
</context-param>
and the level of DispatcherServlet
with: 和
DispatcherServlet
的级别:
<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/ 参考: http : //spring.io/blog/2011/02/11/spring-framework-3-1-m1-released/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.