zoukankan      html  css  js  c++  java
  • 记一次服务启动时bean注入时 Requested bean is currently in creation的问题

    发现测试服务器一台muc启动失败,另一台是好的,本地也没问题,报错信息如下:

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mucAccountLoginController': Injection of resource dependencies failed; 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 'pcAuthorizationServerConfig': Unsatisfied dependency expressed through field 'authenticationManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'formAuthenticationConfig'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'formAuthenticationConfig' defined in URL [jar:file:/home/rockysaas/muc/rockysaas-provider-muc.jar!/BOOT-INF/lib/rockysaas-security-core-1.0.jar!/com/rockysaas/security/core/authentication/FormAuthenticationConfig.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pcAuthenticationSuccessHandler': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'defaultAuthorizationServerTokenServices': Requested bean is currently in creation: Is there an unresolvable circular reference?

    原因是原先有

    public class PcAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
    
        @Resource
        private ObjectMapper objectMapper;
    
        @Resource
        private ClientDetailsService clientDetailsService;
    
        @Autowired
        private PasswordEncoder passwordEncoder;
    
        @Resource
        private MucAccountService mucAccountService;
    
        @Resource
        private MucPlatformMapper mucPlatformMapper;
    
        @Resource
        private AuthorizationServerTokenServices authorizationServerTokenServices;

    后来mucAccountLoginController加了段代码

    
    

    @RestController

    public class MucAccountLoginController extends BaseController {
    
        @Resource
        private MucLoginService mucLoginService;
        @Resource
        private MucAccountTokenService mucUserTokenService;
        @Resource
        private ClientDetailsService clientDetailsService;
        @Autowired
        private PasswordEncoder passwordEncoder;
    
        @Resource
        private MdcApplicationFeignApi mdcApplicationFeignApi;
    
        @Resource
        private AuthorizationServerTokenServices authorizationServerTokenServices;

    原先只有一个AuthorizationServerTokenServices需要注入,现在变成两个,如果同时发生注入的时候就会报错。在其中一个要注入的类上上加上@Lazy就好了

    @RestController
    @RequestMapping(value = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @Api(tags = "Web - 账号登录相关", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public class MucAccountLoginController extends BaseController {
    
        @Resource
        private MucLoginService mucLoginService;
        @Resource
        private MucAccountTokenService mucUserTokenService;
        @Resource
        private ClientDetailsService clientDetailsService;
        @Autowired
        private PasswordEncoder passwordEncoder;
    
        @Resource
        private MdcApplicationFeignApi mdcApplicationFeignApi;
    
        @Resource
        @Lazy
        private AuthorizationServerTokenServices authorizationServerTokenServices;
    喜欢艺术的码农
  • 相关阅读:
    大数据离线分析平台 JavaSDK数据收集引擎编写
    大数据离线分析平台 需求分析(三)
    大数据离线分析平台 需求分析(二)
    大数据离线分析平台 需求分析(一)
    Hive 严格模式与非严格模式
    MapReduce案例:统计共同好友+订单表多表合并+求每个订单中最贵的商品
    Hadoop 目录分析及存储机制
    zookeeper 启动显示started,jps查看进程却没有,解决方法
    Azkaban介绍+安装部署+实战案例
    Flume 高可用配置案例+load balance负载均衡+ 案例:日志的采集及汇总
  • 原文地址:https://www.cnblogs.com/zjhgx/p/12158698.html
Copyright © 2011-2022 走看看