title: Spring Couldn't autowired,there is more than one bean of `` type
body: <p>Here is my question:I have a base interface and two implementation class.</p>
  
  <p>And a Service class has a dependencies on the base interface, the code is like this:</p>
  
  <pre><code>@Component
  public interface BaseInterface {}
  </code></pre>
  
  <hr>
  
  <pre><code>@Component
  public class ClazzImplA implements  BaseInterface{}
  </code></pre>
  
  <hr>
  
  <pre><code>@Component
  public class ClazzImplB implements  BaseInterface{}
  </code></pre>
  
  <hr>
  
  <p>And the configuration is like this :</p>
  
  <pre><code>@Configuration
  public class SpringConfig {
      @Bean
      public BaseInterface clazzImplA(){
          return new ClazzImplA();
      }
  
      @Bean
      public BaseInterface clazzImplB(){
          return new ClazzImplB();
      }
  }
  </code></pre>
  
  <hr>
  
  <p>The service class has dependencies on the base interface will decide to autowire which Implementation by some business logic.And the code is like this:</p>
  
  <hr>
  
  <pre><code>@Service
  @SpringApplicationConfiguration(SpringConfig.class)
  public class AutowiredClazz {
      @Autowired
      private BaseInterface baseInterface;
  
      private AutowiredClazz(BaseInterface baseInterface){
          this.baseInterface = baseInterface;
      }
  }
  </code></pre>
  
  <p>And the IDEA throws a exception:Could not autowire.There is more than one bean of <code>BaseInterface</code> type.</p>
  
  <p>Although it can be solved by using @Qualifier,but in this situation I can't choose the dependencies class.</p>
  
  <pre><code>@Autowired
  @Qualifier("clazzImplA")
  private BaseInterface baseInterface;
  </code></pre>
  
  <p>I tried to read the spring document and it provide a <strong><code>Constructor-based dependency injection</code></strong> but I'm still confused by the problem.</p>
  
  <p>can anyone help me ?</p>