我有一个像这样的内部类的类:
package myPackage;
public class A {
private B b;
public void setB(B b) { this.b = b; }
public B getB() { return this.b; }
public class B {
}
}
我的弹簧配置如下:
<bean id="a" class="myPackage.A" autowire="byName" scope="prototype">
<property name="b">
<bean class="myPackage.A$B" name="b" autowire="byName" scope="prototype">
<constructor-arg ref="a"/>
</bean>
</property>
</bean>
但我面临这个错误:
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'a': Requested bean is currently in creation: Is there an unresolvable circular reference?
当然,很明显我有一个循环引用,但是我的内部类怎么能有一个spring bean呢?