I have a list of animals created by Autowiring.
public class UserManagerConfig {
@Bean
public Dog getDog(){
return new Dog("Lucky");
}
@Bean Cat getCat(){
return new Cat("Charles");
}
}
public class Zoo {
@Autowired
private List<Animal> animals;
}
I would like to add a getDogs() that appends more dogs to the autowired list:
@Bean
public List<Animal> getDogs(){
return new ArrayList<>(Arrays.asList(new Dog("Ray"), new Dog("Soos")));
}
But Spring is not choosing getDogs() while autowiring, it makes a list of beans configured before getDogs() (returning Animal and not List).
Is there a way to tell spring to add this list?