SpringSecurity3.2y启动报Exception starting filter springSecurityFilter错误解决办法

来源:互联网 发布:java内部类 编辑:程序博客网 时间:2024/06/07 14:16

用SpringSecurity3.2作权限管理时,在web.xml中

<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>

启动时报错

org.apache.catalina.core.StandardContext filterStartSEVERE: Exception starting filter springSecurityFilterChainorg.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined

我的解决办法是把filter放到spring的listener之后启动正常,如下:


  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
 
  <!-- Spring Security 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>


以上是原创


另外网上有人说在applicationContext-security.xml中加入<http auto-config='true'></http>即可,但我试过后仍然报错,没有效果。

另外一篇文章说是将http的auto-config改为false,我没试过不知有效果

<http auto-config="false" session-fixation-protection="none">    <form-login login-page="/login.jsp" default-target-url="/home.htm" /></http>

<authentication-provider>   <user-service id="userDetailsService">      <user password="password" name="username" authorities="ROLE_USER" />   </user-service></authentication-provider>

转自 http://blog.csdn.net/kaiwii/article/details/6916353

0 0
原创粉丝点击