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

查看:24
本文介绍了获取错误 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: 没有定义名为springSecurityFilterChain"的 bean

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

我该如何解决这个错误?

How can I resolve this error?

我在 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 文档:

From the DelegatingFilterProxy docs:

注意过滤器实际上是一个DelegatingFilterProxy,而不是将实际实现的类过滤器的逻辑什么DelegatingFilterProxy 确实是 delegate过滤器的方法到 bean这是从 Spring 中获得的应用上下文.这使bean 从 Spring web 中受益应用上下文生命周期支持和配置灵活性.该bean 必须实现javax.servlet.Filter 并且它必须有同名过滤器名称元素.阅读 Javadoc为 DelegatingFilterProxy 更多信息

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

您需要定义一个名为 springSecurityFilterChain 的 bean,它在您的应用程序上下文中实现了 javax.servlet.Filter.

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

来自 安全入门命名空间配置:

如果您熟悉预命名空间框架的版本,你可以大概已经猜到是什么了继续在这里. 元素是负责创建一个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.

所以你至少需要 一个最小 配置

So you need at least A Minimal <http> Configuration

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

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