我在尝试自动装配同一类中定义的bean时遇到问题。
这是我的代码:
@Configuration
public ClassName ..
@Autowired
@Qualifier("myCustomBean")
private MyCustomClass myBean;
@Bean("myCustomBean")
public MyCustomClass getMyCustomBean() {
MyCustomClass c = new MyCustomClass();
return c;
}
@Bean("otherBeanThatIwant")
public OtherClassOfMyProject() {
OtherClass oc = new ...
oc.setMyCustomClass(this.c);
return oc;
}
此代码给出了一个错误,例如: BeanCreationException :创建名称为" otherBeanThatIwant"
的bean时出错... ... ......
无法自动装配字段myBean ...... .... BeanCurrentlyInCreationException 。
我谷歌,但我无法找到问题的答案。
有任何线索吗?
谢谢你的建议! 问候