Unsatisfied dependency expressed through field ‘authorizationServerTokenServices‘

使用SpringSecurityOauth2启动异常:

ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘openIdAuthenticationSecurityConfig’: Unsatisfied dependency expressed through field ‘ygerAuthenticationSuccessHandler’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘ygerAuthenticationSuccessHandler’: Unsatisfied dependency expressed through field ‘authorizationServerTokenServices’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration’: Unsatisfied dependency expressed through field ‘configurers’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘ygerAuthorizationServerConfig’: Unsatisfied dependency expressed through field ‘authenticationManager’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.authentication.AuthenticationManager’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2020-12-03 14:54:16.351 INFO 4512 — [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]

解决办法:
核心上面已经标记出来,添加一个配置类就好了:

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * @author liurui
 * @date 2019年11月25日
 */
@Configuration
public class ConfigurationUpdateBean extends WebSecurityConfigurerAdapter {

    @Bean
    @Override
    public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
根据提供的引用内容,"Unsatisfied dependency expressed through field"错误通常发生在Spring Boot应用程序中,表示在注入依赖时出现问题。这个错误通常是由于以下原因之一引起的: 1. 依赖注入失败:可能是由于没有正确配置或声明依赖项所导致的。请确保在类中正确注解了需要注入的依赖项,并且依赖项的配置正确。 2. 循环依赖:可能是由于循环依赖关系导致的。循环依赖是指两个或多个类之间相互依赖,形成了一个闭环。在Spring中,循环依赖是不允许的,因此会导致"Unsatisfied dependency expressed through field"错误。解决循环依赖问题的方法是重新设计类之间的依赖关系,或者使用构造函数注入代替字段注入。 3. 依赖项未找到:可能是由于依赖项未正确配置或未在应用程序的类路径中找到所导致的。请确保依赖项的配置正确,并且相关的依赖项已经添加到项目的依赖项列表中。 以下是解决"Unsatisfied dependency expressed through field"错误的一些常见方法: 1. 检查依赖项的注解和配置,确保它们正确地注入到需要它们的类中。 2. 检查是否存在循环依赖关系,并尝试重新设计类之间的依赖关系。 3. 检查依赖项的配置和类路径,确保它们正确地配置和添加到项目中。 4. 如果使用的是Spring Boot和MyBatis-Plus,可以尝试重新启动应用程序并启用调试模式,以查看更详细的错误信息和条件报告。 希望这些信息对您有所帮助!如果您有任何其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东芃9394

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值