title: Spring: Injecting list of all concrete classes implementing an interface
body: <p>I have an <code>@Service</code> class which contains a <code>List</code> of other <code>@Service</code> classes. That <code>List</code> basically contains <strong>all</strong> the services which <code>implements UniformEventsResearchApi</code>.</p>
  
  <p>Being a rookie with Spring, I'm not sure how I can get Spring to allow me to follow <a href="https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle" rel="nofollow noreferrer">the Open-Closed Principle</a> and thus having that list automagically injected with all of the concrete implementations.</p>
  
  <p>Here is an incomplete UML class diagram:</p>
  
  <p><a href="https://i.stack.imgur.com/5DfLX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5DfLX.png" alt="uml class diagram"></a></p>
  
  <p>And here is some "code":</p>
  
  <pre class="lang-java prettyprint-override"><code>@Service
  public class EventsResearchService {
  
      // todo: this should be Injected automatically
      private List&lt;UniformEventsResearchApi&gt; eventsResearchApis = Arrays.asList(new EventbriteApi());
  
  // Already tried, but without success:
  //
  //    @Autowired
  //    private List&lt;UniformEventsResearchApi&gt; eventsResearchApis2;
  //
  //    @Autowired
  //    @Qualifier("EventsResearchApi")
  //    public void setXList(List&lt;UniformEventsResearchApi&gt; apis) {
  //        this.eventsResearchApis2 = apis;
  //    }
  
  }
  
  
  @Service
  @Qualifier("EventsResearchApi")
  public interface UniformEventsResearchApi { /* ... */ }
  
  
  public abstract class EventsResearchApi implements UniformEventsResearchApi { /* ... */ }
  
  
  /** Any class like this one which extends EventsResearchApi should be automatically injected in the List */
  public class EventbriteApi extends EventsResearchApi { /* ... */ }
  </code></pre>