当父类构造函数获取该类型的列表时,如何在子类中将bean作为构造函数参数注入。
@Service
public class Parent{
private List<MyObject> myObjectList;
public Parent(List<MyObject> myObjectList){
this.myObjectList = myObjectList;
}
}
@Service
public class Child extends Parent {
@Autowired
public Child(MyObject myObject){
super( ???? );
}
}
答案 0 :(得分:4)
这个怎么样?
super(Arrays.asList(new MyObject[] {myObject}));