Requested bean is currently in creation: Is there an unresolvable circular reference?


spring容器初始化报错:循环依赖,错误信息如下:

Requested bean is currently in creation: Is there an unresolvable circular reference?

与网上其他人A->B->C->A循环调用的情况不同,我这里是同一个类A,用@Service注解做了定义,又在其他地方用@Bean做了重复申明导致。

如下

@Service

class A {

}

 

class B {

     @Bean

     public A a() {

    return new A();

  }

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM