每当我运行Spring MVC应用程序时,我都会遇到此错误。我一直在尝试集成Spring Security,但是在注入我的自定义AuthenticationSuccessHandler方面却没有成功,因此我收到了与应用程序上下文有关的以下错误:
2017-11-07 16:05:03 ERROR ContextLoader:350 - Context initialization failed
org.springframework.beans.factory.UnsatisfiedDependencyException: \
Error creating bean with name 'webSecurityConfig': \
Unsatisfied dependency expressed through field 'auth'; \
nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: \
No qualifying bean of type \
'org.springframework.security.web.authentication.AuthenticationSuccessHandler' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
我在GitHub上有我的项目:https://github.com/riveraadrian571/Staging-Management-System-Modifed-.git。我正在使用oracle数据库并在pom.xml文件中使用我在本地存储库中的jdbc驱动程序,因此您可能想要更改它。我也使用tomcat服务器来运行应用程序。提前谢谢。
答案 0 :(得分:0)
在WebSecurityConfig中你有
@Autowired
AuthenticationSuccessHandler auth;
哪个是界面。您需要从标准中指定任何特定的实现:
所有已知的实施类:
ForwardAuthenticationSuccessHandler,
SavedRequestAwareAuthenticationSuccessHandler,
SimpleUrlAuthenticationSuccessHandler
@see Spring Docs
或实施您的自定义。