Reputation: 17
How to inject a bean as a constructor argument in a child class when the parent class constructor takes a list of that type.
@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( ???? );
}
}
Upvotes: 0
Views: 148
Reputation: 62864
What about this ?
super(Arrays.asList(new MyObject[] {myObject}));
Upvotes: 4