我目前正在使用spring-flex集成并希望添加通过spring保护的web服务。使用名称'_loginCommandPostProcessor'创建bean时出错
为此,我试图创建两个http标记?
弹簧安全-config.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<context:component-scan base-package="com.somenamespace.login" />
<context:annotation-config/>
<beans:bean id="entryPoint"
class="org.springframework.flex.security4.FlexAuthenticationEntryPoint"/>
<http entry-point-ref="entryPoint" pattern="/messagebroker/**">
<intercept-url pattern="/**" access="authenticated"/>
<custom-filter position="FORM_LOGIN_FILTER" ref="myAuthFilter" />
<session-management session-authentication-strategy-ref="sas"/>
</http>
<http pattern="*">
<intercept-url pattern="/**" access="authenticated"/>
<http-basic />
<custom-filter position="FORM_LOGIN_FILTER" ref="myAuthFilter" />
<session-management session-authentication-strategy-ref="sas"/>
</http>
<beans:bean id="myAuthFilter" class=
"org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<beans:property name="sessionAuthenticationStrategy" ref="sas" />
<beans:property name="authenticationManager" ref="authenticationManager" />
</beans:bean>
<beans:bean id="sas" class="org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy" />
<beans:bean id="switchUserProcessingFilter" class="org.springframework.security.web.authentication.switchuser.SwitchUserFilter">
<beans:property name="userDetailsService" ref="customAuthenticationProvider"/>
<beans:property name="switchUserUrl" value="/admin/impersonate"/>
<beans:property name="targetUrl" value="/cre/CRE.html"/>
<beans:property name="switchFailureUrl" value="/admin/switchUser"/>
</beans:bean>
<beans:bean id="defaultMessageTemplate" class="org.springframework.flex.messaging.MessageTemplate" />
<beans:bean id="customAuthenticationProvider" class="com.somenamespace.login.CustomAuthenticationProvider"/>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="customAuthenticationProvider"/> <
</authentication-manager>
</beans:beans>
,我发现了以下错误:
Error creating bean with name '_loginCommandPostProcessor': Unsatisfied dependency expressed through bean property 'sessionAuthenticationStrategy'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.security.web.authentication.session.SessionAuthenticationStrategy' available: expected single matching bean but found 3: org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy#0,org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy#1,sas
从错误中可以清楚地看出,除了'sas'之外,你在spring的context中初始化了2个bean。你确定你没有扫描'org.springframework.security.web.authentication.session'吗?它可以在其他xml文件中声明。 –
我不确定这意味着什么。我如何确保我没有扫描它? – DangeRuss
我已经发布我的回答您的问题作为下面的答案与可能的解决方案,请看看。 –