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

前端之家收集整理的这篇文章主要介绍了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();

  }

}

 

猜你在找的Spring相关文章