Kimble
Kimble

Reputation: 7574

Spring dependency injection: Inject all instances of interface

How, if possible can I configure a Spring bean with all a collection of other Spring beans that implements a specific interface?

Example: I want to wire the CarFactory bean with a list of beans implementing the CarManufacturer interface.

Upvotes: 14

Views: 9259

Answers (1)

Bozho
Bozho

Reputation: 597412

@Inject
private List<CarManufacturer> manufacturers;

Upvotes: 23

Related Questions