BeanCurrentlyInCreationException This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesForType' with the 'allowEagerInit' flag turned off, for example.


这个问题是循环依赖引起,如下代码演示:



 public class ClassA {
    @Autowired
    ClassB classB;
}

public class ClassB {
    @Autowired
    ClassA classA ;
}


解决方案,再加上@Lazy 注解即可,如下:




public class ClassA {
    @Lazy
    @Autowired
    ClassB classB;
}

public class ClassB {
    @Lazy
    @Autowired
    ClassA classA ;
}














点赞(0) 打赏

Comment list 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部