获取错误org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义名为'springSecurityFilterChain'的bean [英] Getting error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined

查看:108
本文介绍了获取错误org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义名为'springSecurityFilterChain'的bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring Security运行NTLM,我收到以下错误

I am running NTLM using Spring Security, I am getting the following error


org.springframework.beans.factory.NoSuchBeanDefinitionException:No名为'springSecurityFilterChain'的bean已定义

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined

如何解决此错误?

我在web.xml中定义了以下内容

I have the following defined in 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>

更新1

我解决了这个错误,现在我得到了

I resolved that error, now I am getting


org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义名为'filterSecurityInterceptor'的bean

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'filterSecurityInterceptor' is defined

我有以下

<bean id="springSecurityFilterChain" class="org.acegisecurity.util.FilterChainProxy">
    <property name="filterInvocationDefinitionSource">
    <value>
    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    PATTERN_TYPE_APACHE_ANT
    /**=httpSessionContextIntegrationFilter, exceptionTranslationFilter, ntlmFilter, filterSecurityInterceptor
    </value>
    </property>
    </bean>`






我改变了我的applicationContext.xml如下所示,因为就像@Sean Patrick Floyd所提到的那样,一些元素已经老了,已经死了并埋葬了。但是我现在还有其他错误需要修复: - )


I changed my applicationContext.xml as follows because like @Sean Patrick Floyd mentioned some elements were old and dead and buried. However I have other errors now which needs to be fixed :-)

谢谢

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:security="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd   http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.2.xsd">
  <!--<authentication-manager alias="_authenticationManager"></authentication-manager>-->
  <security:authentication-provider>
    <security:user-service>
      <security:user name="testuser" password="PASSWORD" authorities="ROLE_USER, ROLE_ADMIN"/>
      <security:user name="administrator" password="PASSWORD" authorities="ROLE_USER,ROLE_ADMIN"/>
    </security:user-service>
  </security:authentication-provider>
  <bean id="userDetailsAuthenticationProvider"
        class="com.icesoft.icefaces.security.UserDetailsAuthenticationProvider">
    <security:custom-authentication-provider/>
  </bean>
  <bean id="ntlmEntryPoint"
        class="org.springframework.security.ui.ntlm.NtlmProcessingFilterEntryPoint">
    <property name="authenticationFailureUrl" value="/accessDenied.jspx"/>
  </bean>
  <bean id="ntlmFilter" class="org.springframework.security.ui.ntlm.NtlmProcessingFilter">
    <security:custom-filter position="NTLM_FILTER"/>
    <property name="stripDomain" value="true"/>
    <property name="defaultDomain" value="domain"/>
    <property name="netbiosWINS" value="domain"/>
    <property name="authenticationManager" ref="_authenticationManager"/>
  </bean>
  <bean id="exceptionTranslationFilter"
        class="org.springframework.security.ui.ExceptionTranslationFilter">
    <property name="authenticationEntryPoint" ref="ntlmEntryPoint"/>
  </bean>
  <security:http access-decision-manager-ref="accessDecisionManager"
                 entry-point-ref="ntlmEntryPoint">
    <security:intercept-url pattern="/accessDenied.jspx" filters="none"/>
    <security:intercept-url pattern="/**" access="ROLE_USER"/>
  </security:http>
  <bean id="accessDecisionManager" class="org.springframework.security.vote.UnanimousBased">
    <property name="allowIfAllAbstainDecisions" value="false"/>
    <property name="decisionVoters">
      <list>
        <bean id="roleVoter" class="org.springframework.security.vote.RoleVoter"/>
      </list>
    </property>
  </bean>
</beans>


推荐答案

来自DelegatingFilterProxy docs:

From the DelegatingFilterProxy docs:


请注意,过滤器实际上是
DelegatingFilterProxy,而不是实际实现的
类过滤器的
逻辑。什么
DelegatingFilterProxy做的是委托
Filter的方法到bean
,它是从Spring
应用程序上下文
获得的。这使得
bean可以从Spring Web
应用程序上下文生命周期支持
和配置灵活性中受益。
bean必须实现
javax.servlet.Filter,它必须与
filter-name元素
中的
同名。阅读DelegatingFilterProxy的Javadoc
以获取更多
信息

Notice that the filter is actually a DelegatingFilterProxy, and not the class that will actually implement the logic of the filter. What DelegatingFilterProxy does is delegate the Filter's methods through to a bean which is obtained from the Spring application context. This enables the bean to benefit from the Spring web application context lifecycle support and configuration flexibility. The bean must implement javax.servlet.Filter and it must have the same name as that in the filter-name element. Read the Javadoc for DelegatingFilterProxy for more information

您需要定义一个名为<$ c $的bean c> springSecurityFilterChain 在您的应用程序上下文中实现 javax.servlet.Filter

You need to define a bean named springSecurityFilterChain that implements javax.servlet.Filter in your application context.

安全命名空间配置入门


如果你熟悉框架的pre-namespace
版本,你可以
已经大致猜到了这里发生的
< http> 元素是
,负责创建
FilterChainProxy 和过滤器bean
,它使用
。像
不正确的过滤器排序这样的常见问题不再是
,因为过滤器
的位置是预定义的。

If you are familiar with pre-namespace versions of the framework, you can probably already guess roughly what's going on here. The <http> element is responsible for creating a FilterChainProxy and the filter beans which it uses. Common problems like incorrect filter ordering are no longer an issue as the filter positions are predefined.

所以你至少需要 A Minimal < http> 配置

So you need at least A Minimal <http> Configuration

这篇关于获取错误org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义名为'springSecurityFilterChain'的bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆