我在将Spring安全性版本3迁移到4时遇到此异常。我正在使用基于Sprig 4 XML的安全性来实现它。您将非常感激
异常:
引起:org.springframework.beans.factory.BeanCreationException:创建名称为' util:list的错误#list#f1d6071':无法创建内部bean' security:filter-chain#1c5c0deb&# 39;的 在设置bean属性' sourceList'时键入[org.springframework.security.web.DefaultSecurityFilterChain]。用钥匙[10];嵌套异常是org.springframework.beans.factory.Bea nCreationException:创建名称为' security的bean时出错:filter-chain#1c5c0deb':C annot解析对bean的引用' adminConsoleDeniedExceptionTranslationFilter'同时设置公司 带键[5]的nstructor参数;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为' adminConsoleDeniedExceptionTranslationF的bean时出错 ILTER'在ServletContext资源[/WEB-INF/spring-security.xml]中定义:无法解析匹配的构造函数(提示:为简单参数指定索引/类型/名称参数 空洞类型歧义)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE] 在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEAS E]
spring-security.xml(受影响的Spring 4 XML配置的一小部分)
<bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy">
<constructor-arg>
<util:list>
<security:filter-chain pattern="/refreshCache**" filters="scpf,noFilter,logoutFilter"/>
<security:filter-chain pattern="/admin/adminConsole/**" filters="scpf,dsToSpringFilter,securityFilter,logoutFilter,
fsi,adminConsoleDeniedExceptionTranslationFilter,adminConsoleFilter"/>
</util:list>
</constructor-arg>
</bean><bean id="etf"
class="org.springframework.security.web.access.ExceptionTranslationFilter">
<constructor-arg name="authenticationEntryPoint" ref="preAuthenticatedProcessingFilterEntryPoint"/>
</bean><bean id="adminConsoleDeniedExceptionTranslationFilter" class="org.springframework.security.web.access.ExceptionTranslationFilter">
<constructor-arg name="authenticationEntryPoint2" ref="preAuthenticatedProcessingFilterEntryPoint"/>
<constructor-arg ref="adminConsoleAccessDeniedHandler"/></bean><bean id="preAuthenticatedProcessingFilterEntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/><bean id="adminConsoleAccessDeniedHandler" class="org.springframework.security.web.access.AccessDeniedHandlerImpl"><property name="errorPage" value="/WEB-INF/jsp/adminConsoleAccessDenied.jsp"/></bean>
答案 0 :(得分:1)
第一个构造函数-arg(bean adminConsoleDeniedExceptionTranslationFilter
)中的Name属性具有奇怪的值authenticationEntryPoint2
:
<bean id="adminConsoleDeniedExceptionTranslationFilter" class="org.springframework.security.web.access.ExceptionTranslationFilter">
<constructor-arg name="authenticationEntryPoint2" ref="preAuthenticatedProcessingFilterEntryPoint"/>
<constructor-arg ref="adminConsoleAccessDeniedHandler"/>
</bean>
根据documentation,它应为authenticationEntryPoint
。
而且,第二个构造函数-arg没有name
属性。请考虑添加name
属性,或删除两者。