title: Multiple implementations in Spring
body: <p>I've got TopicGenerator interface:</p>
  
  <pre><code>public interface TopicGenerator {
      File create(MultiValueMap params);
      boolean accept(MultiValueMap params);
  }
  </code></pre>
  
  <p>And 3 implementations:</p>
  
  <pre><code>@RequiredArgsConstructor
  public class JavaTopicGenerator implements TopicGenerator {
  //implementation ommited for readability
  
  @RequiredArgsConstructor
  public class PhpTopicGenerator implements TopicGenerator {
  //implementation ommited for readability
  
  @RequiredArgsConstructor
  public class CppTopicGenerator implements TopicGenerator {
  //implementation ommited for readability
  </code></pre>
  
  <p>Now what I try to do is use them depending on my params thats why I created special TopicFacade.</p>
  
  <pre><code>@RequiredArgsConstructor
  public class TopicFacade {
  
      @NonNull
      private final TopicService topicService;
  
      @NonNull
      private final List&lt;TopicGenerator&gt; topicGenerators;
  
      public void generate(MultiValueMap&lt;String, String&gt; params, HttpServletResponse response) {
          for (TopicGenerator topicGenerator : topicGenerators) {
              if (topicGenerator.accept(params)) {
                  File tempFile = topicService.generate(params);
                  //do something else.
              }
          }
      }
  }
  </code></pre>
  
  <p>Where on my TopicServiceImpl I've got:</p>
  
  <pre><code>@Service
  @RequiredArgsConstructor
  public class TopicServiceImpl implements TopicService {
  
      @NonNull
      private final List&lt;TopicGenerator&gt; reportGenerators;
  
          public File generate(MultiValueMap params) {
          for (TopicGenerator topicGenerator : topicGenerators) {
              if (topicGenerator.create(params)) {
                  return topicGenerator.export(params);
              }
          }
  </code></pre>
  
  <p>I get an error like:
  <code>Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'topicServiceImpl': Unsatisfied dependency expressed through field 'topicGenerators'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.List&lt;com.topic.service.TopicGenerator&gt;' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}</code></p>
  
  <p>(Earlier when I was using field injection instead of constructor I was able to add <code>@Service</code> before one of the 3 implementation and code was working was working on that single implementation, but its not what I'm looking for)</p>