title: spring autowire multiple implementation
body: <p>I need to autowire interface which has couple of implementation. I'm using @Qualifier to achieve this-</p>
  
  <p><strong>Interface DataSourceConfig</strong></p>
  
  <pre><code>public interface DataSourceConfig {
    DataSource getDataSource();
  }
  </code></pre>
  
  <p><strong>Implementation 1:</strong></p>
  
  <pre><code>@Configuration("mysql")
  public class MySqlDataSourceConfig implements DataSourceConfig {
  
  @Bean
  public DataSource getDataSource() {
      System.out.println("MySQL datasource");
  
      //some implementation
  
      return dataSource;
   }
  }
  </code></pre>
  
  <p><strong>Implementation 2:</strong></p>
  
  <pre><code>@Configuration("hsql")
  public class HsqlDataSourceConfig implements DataSourceConfig {
  
  @Bean
  public DataSource getDataSource() {
      System.out.println("hsql dataSource");
      return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).addScript(
              "classpath:database/schema.sql").addScript(
              "classpath:database/datascript.sql").build();
     }
  }
  </code></pre>
  
  <p><strong>Client:</strong></p>
  
  <pre><code>@Configuration
  public class Client {
  
   @Autowired
   @Qualifier("hsql")
   DataSourceConfig hsqlDataSource;
  
   @Autowired
   @Qualifier("mysql")
   DataSourceConfig mysqlDataSource;
  
  }
  </code></pre>
  
  <p>Only one datasource (mysqlDataSource) is being created and i see the following message in my log. It's in INFO mode though -</p>
  
  <pre><code>org.springframework.beans.factory.support.DefaultListableBeanFactory.registerBeanDefinition Overriding bean definition for bean 'hsqlDataSource':
  </code></pre>