【发布时间】:2014-08-08 00:52:15
【问题描述】:
我创建了一个 bean,它期望注入给定类型的所有 bean... 像这样:
public class MyClass {
private List<MyOtherBean> myOtherBeansList;
....
@Inject
public void setMyOtherBeanList(List<MyOtherBean> otherBeanList) {
this.myOtherBeansList = otherBeanList;
}
这很好用,除非我没有定义“MyOtherBeans”类型的 bean。在我的业务逻辑中,没关系!但是spring不喜欢,抛出了过于熟悉的:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type...
异常。有谁知道在这种情况下让 spring 传递给我 null 的方法?
【问题讨论】:
标签: spring