title: Configure SpringBoot+Hibernate+PostgreSQL
body: <p>I'm totally noob in PostgreSQL and configuring Spring web applications, plus all info I could found about this is on Maven or for Eclipse, so very hard for me understand cause I'm using IntelliJ + Gradle. Installed Postgres v 9.5.4.2 on my iMac and started simple web app:</p>
  
  <p><strong>UPDATE</strong>: All fixes made, M. Deinum, gradle-2.13 is ok for SpringBoot?</p>
  
  <p>Project structure:</p>
  
  <p><a href="https://i.stack.imgur.com/RBEGR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RBEGR.png" alt="enter image description here"></a></p>
  
  <p>build.gradle:</p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '1.3.7.RELEASE'
      }
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'idea'
  apply plugin: 'spring-boot'
  
  jar {
      baseName = 'TryPostgreSQL'
      version = '0.0.1-SNAPSHOT'
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile 'org.springframework.boot:spring-boot-starter-web'
      compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
      compile 'org.springframework.boot:spring-boot-starter-data-jpa'
      compile 'org.springframework.boot:spring-boot-starter-security'
      compile 'org.springframework.boot:spring-boot-starter-aop'
      compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity4'
      compile 'com.google.code.gson:gson'
      compile 'org.postgresql:postgresql'
  
      testCompile 'org.springframework.boot:spring-boot-starter-test'
      testCompile("org.dbunit:dbunit:2.5.1")
      testCompile("com.github.springtestdbunit:spring-test-dbunit:1.2.1")
      testCompile("net.sourceforge.htmlunit:htmlunit:2.20")
      testCompile("org.easytesting:fest-assert:1.4")
      testCompile ("org.springframework.security:spring-security-test")
  }
  
  task wrapper(type: Wrapper) {
      gradleVersion = '3.0'
  }
  
  task stage {
      dependsOn build
  }
  </code></pre>
  
  <p>Application.java</p>
  
  <pre><code>@SpringBootApplication
  public class Application {
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>application.properties (no idea why, but dialect attribute is bold red):</p>
  
  <pre><code># Details for our datasource
  spring.datasource.url = jdbc:postgresql://localhost:5432/database
  spring.datasource.username = postgres
  spring.datasource.password = postgres
  
  # Hibernate properties
  spring.jpa.database = org.hibernate.dialect.PostgreSQLDialect
  spring.jpa.show-sql = false
  spring.jpa.hibernate.ddl-auto = create-drop
  spring.jpa.hibernate.naming.implicit-strategy = org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
  spring.jpa.properties.hibernate.format_sql=true
  </code></pre>
  
  <p>And error message of course:</p>
  
  <pre><code>2016-09-16 09:17:19.978  WARN 773 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: 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 org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
  2016-09-16 09:17:19.985  INFO 773 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
  2016-09-16 09:17:19.996 ERROR 773 --- [           main] o.s.boot.SpringApplication               : Application startup failed
  
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: 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 org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
  </code></pre>
  
  <p>Other code - just usual model (my entities), dao (Crud repositories), service and controllers.
  Anyway I can't even start it, getting this error message right after boot:</p>
  
  <p>I will be greatly appreciated for any help to start this program and connect it to PostgeSQL database.</p>
  
  <p><strong>UPDATE 2:</strong>
  Moved. Refreshed. Error:</p>
  
  <pre><code>Properties configuration failed validation
  2016-09-16 09:41:53.696 ERROR 883 --- [           main] o.s.b.b.PropertiesConfigurationFactory   : Field error in object 'spring.jpa' on field 'database': rejected value [org.hibernate.dialect.PostgreSQLDialect]; codes [typeMismatch.spring.jpa.database,typeMismatch.database,typeMismatch.org.springframework.orm.jpa.vendor.Database,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.jpa.database,database]; arguments []; default message [database]]; default message [Failed to convert property value of type [java.lang.String] to required type [org.springframework.orm.jpa.vendor.Database] for property 'database'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [org.springframework.orm.jpa.vendor.Database] for value 'org.hibernate.dialect.PostgreSQLDialect'; nested exception is java.lang.IllegalArgumentException: No enum constant org.springframework.orm.jpa.vendor.Database.org.hibernate.dialect.PostgreSQLDialect]
  </code></pre>
  
  <p><strong>UPDATE 3:</strong>
  Changed name of property in application.property from database to dialect. Application started!</p>