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();

  }

}

原文地址:https://www.cnblogs.com/cocoat/p/7687186.html