我正在尝试使用spring security SAML(spring security 4.0.1和saml 1.0.1)设置SSO,但在启动时出现以下错误:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.saml.log.SAMLLogger] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1320)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:961)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:616)
... 91 more
这是我的背景:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd">
...
<security:http pattern="/saml/**" create-session="stateless" entry-point-ref="samlEntryPoint">
<security:intercept-url pattern="/**" access="hasRole('ROLE_RUN')" />
<security:custom-filter before="FIRST" ref="metadataGeneratorFilter"/>
<security:custom-filter after="BASIC_AUTH_FILTER" ref="samlFilter"/>
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="admin" password="!@#$torch" authorities="ROLE_ADMIN" />
</security:user-service>
</security:authentication-provider>
<security:authentication-provider ref="samlAuthenticationProvider" />
</security:authentication-manager>
<context:annotation-config/>
<context:component-scan base-package="org.springframework.security.saml"/>
<bean id="keyManager" class="org.springframework.security.saml.key.JKSKeyManager">
<constructor-arg value="classpath:saml/samlKeystore.jks"/>
<constructor-arg type="java.lang.String" value="torch1234"/>
<constructor-arg>
<map>
<entry key="torchlms" value="torch1234"/>
</map>
</constructor-arg>
<constructor-arg type="java.lang.String" value="torchlms"/>
</bean>
<bean id="samlAuthenticationProvider" class="org.springframework.security.saml.SAMLAuthenticationProvider">
<property name="userDetails" ref="samlUserDetailsServiceImpl" />
<property name="forcePrincipalAsString" value="false" />
</bean>
<bean id="samlUserDetailsServiceImpl" class="com.prometheus.torchlms.security.saml.SAMLUserDetailsServiceImpl">
<constructor-arg ref="authorizationService" />
<constructor-arg ref="principalHolderService" />
</bean>
...
错误让我觉得它缺少组件扫描,但我补充说。我唯一能想到的是我定义上下文命名空间的方式有问题,但这对我来说也是正确的。想法?
答案 0 :(得分:1)
了解所有这些内容的秘诀在于查看示例应用程序上下文文件并粘贴所有内容,然后删除不需要的内容。示例应用程序中有大量内容未在文档中提及。我能够使用这种方法。