title: java.lang.IllegalStateException: No supported DataSource type found
body: <p>Spring boot can't create my Postgres datasource. The error is starting here: </p>
  
  <pre><code>at org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder.getType(DataSourceBuilder.java:138) ~[spring-boot-autoconfigure-1.5.7.RELEASE.jar:1.5.7.RELEASE]
  </code></pre>
  
  <p>Ultimately throwing error:</p>
  
  <pre><code>Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: No supported DataSource type found
  </code></pre>
  
  <p>I've built Spring Apps using xml configuration and Maven, but Spring Boot and Gradle are new to me. I'm used to <code>@Autowire</code> pulling the datasource from the config file. Based on some SO answers, I added a database config class: </p>
  
  <pre><code>import javax.sql.DataSource;
  
  import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
  import org.springframework.boot.context.properties.ConfigurationProperties;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.Primary;
  import org.springframework.context.annotation.PropertySource;
  
  @Configuration
  @PropertySource({ "classpath:application.properties" })
  public class DatabaseConfig {
  
      @Bean
      @Primary
      @ConfigurationProperties(prefix = "spring.datasource")
      public DataSource dataSource() {
  
          return DataSourceBuilder.create().build();
  
      }
  
  }
  </code></pre>
  
  <p>I'm trying to autowire the datasource to my JDBC implementation:</p>
  
  <pre><code>@Component
  public class JDBCRegionNameDAO implements RegionNameDAO {
  
      private JdbcTemplate jdbcTemplate;
  
      @Autowired
      public JDBCRegionNameDAO (DataSource dataSource)  {
          this.jdbcTemplate = new JdbcTemplate(dataSource);
      }
  
  }
  </code></pre>
  
  <p>My application.properties, I've checked my postgres credentials, and ensured the service is running: </p>
  
  <pre><code>spring.datasource.driver-class-name=org.postgresql.Driver
  
  spring.datasource.url=jdbc:postgresql://localhost:5432/world_builder
  spring.datasource.platform=postgres
  spring.datasource.username=postgres
  spring.datasource.password=postgres
  </code></pre>
  
  <p>My build.gradle, from what I've looked at, it seems that I have everything here that I need, but the error being thrown above suggests I'm missing something: </p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '1.5.7.RELEASE'
      }
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'eclipse-wtp'
  apply plugin: 'org.springframework.boot'
  apply plugin: 'war'
  
  group = 'group.group'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = 1.8
  
  repositories {
      mavenCentral()
  }
  
  configurations {
      providedRuntime
  }
  
  dependencies { 
  
      compile('org.springframework.boot:spring-boot-starter-actuator')
      compile('org.springframework.boot:spring-boot-starter-jdbc')
      compile('org.springframework.boot:spring-boot-starter-web')
  
      compile('org.springframework.boot:spring-boot-starter-thymeleaf')
      compile('org.springframework.boot:spring-boot-devtools')
  
      compile group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
  
      runtime('org.postgresql:postgresql')    
  
      providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
      testCompile('org.springframework.boot:spring-boot-starter-test')
  }
  </code></pre>