title: Springboot postgres Failed to determine a suitable driver class
body: <p>I am trying to develop web application using SpringBoot and Postgres Database. However, on connecting to the application, I am getting error "Failed to determine a suitable driver class"
  As per advise in older posts, I have tried using driver of different version of jdbc and also tried creating bean for NamedParameterJdbcTemplate manually. I also validated that libraries are present and is accessible from Java code and those are present in classpath. But its still giving the same issue.
  I am using gradle to import all jars into build path.</p>
  
  <p>Here is the git repository for the code:
  <a href="https://github.com/ashubisht/sample-sbs.git" rel="noreferrer">https://github.com/ashubisht/sample-sbs.git</a></p>
  
  <p>Gradle dependency code:</p>
  
  <pre class="lang-none prettyprint-override"><code>apply plugin: 'idea'
  apply plugin: 'org.springframework.boot'
  apply plugin: 'io.spring.dependency-management'
  
  dependencies {
      compile("org.springframework.boot:spring-boot-starter-web")
      compile("org.springframework.boot:spring-boot-starter-websocket")
      compile("org.springframework.boot:spring-boot-starter-jdbc")
      //compile("org.postgresql:postgresql")
      compile("org.postgresql:postgresql:9.4-1206-jdbc42")
      testCompile("org.springframework.boot:spring-boot-starter-test")
      testCompile group: 'junit', name: 'junit', version: '4.12'
  }
  </code></pre>
  
  <p>Code for building Bean</p>
  
  <pre><code>@Configuration
  @PropertySource("classpath:application.properties")
  public class Datasource {
  
      @Value("${db.driverClassName}")
      private String driverClass;
      @Value("${db.url}")
      private String url;
      @Value("${db.username}")
      private String username;
      @Value("${db.password}")
      private String password;
  
      @Bean
      public NamedParameterJdbcTemplate namedParameterJdbcTemplate() throws Exception{
          System.out.println(driverClass+" "+ url+" "+username+" "+password);
          DriverManagerDataSource source = new DriverManagerDataSource();
          source.setDriverClassName(driverClass);
          source.setUrl(url);
          source.setUsername(username);
          source.setPassword(password);
          NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(source);
          return namedParameterJdbcTemplate;
      }
  }
  </code></pre>
  
  <p>Here is application.properties</p>
  
  <pre class="lang-none prettyprint-override"><code>server.port=8086
  
  #spring.datasource.driverClassName=org.postgresql.Driver
  #spring.datasource.url= jdbc:postgresql://localhost:5432/testdb
  #spring.datasource.username=postgres
  #spring.datasource.password=password
  #spring.datasource.platform=postgresql
  #spring.jpa.hibernate.ddl-auto=create-drop
  
  db.driverClassName=org.postgresql.Driver
  db.url=jdbc:postgresql://localhost:5432/testdb
  db.username=postgres
  db.password=password
  </code></pre>