No bean named 'springSecurityFilterChain' is defined 解决方法

来源:互联网 发布:金山网络2016校园招聘 编辑:程序博客网 时间:2024/05/16 19:53

最近在配置Spring Security 3.0的时候,遇到了这个问题

 

'springSecurityFilterChain' 是默认配置在web.xml中的filter:

 

<filter>
  <filter-name>springSecurityFilterChain</filter-name>
  <filter-class>
   org.springframework.web.filter.DelegatingFilterProxy
  </filter-class>
 </filter>
 <filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name>
  <url-pattern>/*</url-pattern>

</filter-mapping>

 

在tomcat(6.0)启动时就报了上述错误。

 

网上查阅资料发现有些说法是jar冲突,有的说是application-security.xml配置错误,我的解决方法是:

 

修改了context-param的启动路径,原路径是:

 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:applicationContext*.xml</param-value>
 </context-param>

 

修改为绝对路径:

 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/classes/conf/applicationContext*.xml</param-value>
 </context-param>

 

启动就正常了