title: configure multiple datasource with spring including namedparameterjdbctemplate
body: <p>I have the following db config class in my project where i try to configure multiple jdbctemplate and a named jdbc template for one of the two data sources: </p>
  
  <pre><code>@Configuration
  public class DatabaseConfiguration {
  
  @Bean(name = "abcDataSource")
  @Primary
  @ConfigurationProperties(prefix = "spring.datasource")
  public DataSource abcDataSource() {
      return DataSourceBuilder.create().build();
  }
  
  @Bean(name = "jdbcABC")
  @Autowired
  public JdbcTemplate abcJdbcTemplate(@Qualifier("abcDataSource") DataSource datasource) {
      return new JdbcTemplate(datasource);
  }
  
  @Bean(name = "namedJdbcABC")
  public NamedParameterJdbcTemplate namedParameterJdbcTemplate(@Qualifier("abcDataSource") DataSource datasource) {
      return new NamedParameterJdbcTemplate(datasource);
  }
  
  
  @Bean(name = "shDataSource")
  @ConfigurationProperties(prefix = "spring.shdatasource")
  public DataSource shDataSource() {
      return DataSourceBuilder.create().build();
  }
  
  @Bean(name = "jdbcSh")
  @Autowired
  public JdbcTemplate shJdbcTemplate(@Qualifier("shDataSource") DataSource datasource) {
      return new JdbcTemplate(datasource);
  }
  </code></pre>
  
  <p>I seem to have configured everything correctly in my yaml file:</p>
  
  <pre><code>spring:
      profiles:
          active: dev
      output.ansi.enabled: always
  
      shdatasource:
          driverClassName: oracle.jdbc.OracleDriver
          url: jdbc:oracle:thin:@sh.database.url:1521:sid
          username: test
          password: test
      datasource:
          driverClassName: oracle.jdbc.OracleDriver
          url: jdbc:oracle:thin:@abc.db.url:1521:oll
          username: test
          password: test
  </code></pre>
  
  <p>But i get error:</p>
  
  <p><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'somedao': Unsatisfied dependency expressed through field 'namedParameterJdbcTemplate';</code></p>
  
  <p><code>Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'abcDataSource' threw exception; nested exception is java.lang.IllegalStateException: No supported DataSource type found</code></p>
  
  <p>Anybody can tell me If I misconfigured something? </p>