![](/img/trans.png)
[英]Unable to initialize spring through ContextLoaderListener in web.xml
[英]Initialize spring bean profile through ContextLoaderListener in web.xml
在我的web.xml
我正在声明一个ContextLoaderListener
来以这种方式配置spring应用程序:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
在我的一个spring配置xml文件中,我使用不同的bean配置文件进行开发和生产。
<beans profile="production">
<bean />
</beans
<beans profile="development">
<bean />
</beans
我如何在web.xml
设置默认的bean配置文件? 使用ContextLoaderListener
而不是spring servlet时,有类似的内容:
<init-param>
<param-name>spring.profiles.active</param-name>
<param-value>production</param-value>
</init-param>
您可以在ContextLoaderListener
级别配置web.xml
:
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>profileName</param-value>
</context-param>
和DispatcherServlet
的级别:
<init-param>
<param-name>spring.profiles.active</param-name>
<param-value>profileName</param-value>
</init-param>
参考: http : //spring.io/blog/2011/02/11/spring-framework-3-1-m1-released/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.