spring.jpa.hibernate.ddl auto=create不在spring Boot 2.0.0.M2中创建表

spring.jpa.hibernate.ddl auto=create不在spring Boot 2.0.0.M2中创建表,hibernate,spring-boot,spring-data-jpa,Hibernate,Spring Boot,Spring Data Jpa,我将SpingBoot从1.5.3升级到2.0.0.M2。现在hibernate即使使用spring.jpa.hibernate.ddl auto=create也不会创建表。它在Spring Boot 1.5.3下工作。我的部分相关配置如下所示: #database configuration spring.jpa.database=POSTGRESQL spring.jpa.show-sql=true spring.jpa.database-platform=org.hibernate.dia

我将SpingBoot从1.5.3升级到2.0.0.M2。现在hibernate即使使用spring.jpa.hibernate.ddl auto=create也不会创建表。它在Spring Boot 1.5.3下工作。我的部分相关配置如下所示:

#database configuration
spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=true
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost/gzhtestdb
spring.datasource.username=gzhtest
spring.datasource.password=xxxxxxxxxx
spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=generated/sql/create.sql
spring.jpa.hibernate.ddl-auto= create
控制台日志显示:

    2017-07-20 16:22:33.285  INFO 82524 --- [  restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.2.10.Final}
2017-07-20 16:22:33.285  INFO 82524 --- [  restartedMain] 
    org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
    2017-07-20 16:22:33.331  INFO 82524 --- [  restartedMain] org.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
    2017-07-20 16:22:33.519  INFO 82524 --- [  restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
    2017-07-20 16:22:33.597  INFO 82524 --- [  restartedMain] org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
    2017-07-20 16:22:33.597  INFO 82524 --- [  restartedMain] org.hibernate.type.BasicTypeRegistry : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@8858d27
    2017-07-20 16:22:34.408  INFO 82524 --- [  restartedMain] org.hibernate.tool.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@31b797e'
    2017-07-20 16:22:36.546  INFO 82524 --- [  restartedMain] com.cju.BeanProvider : @PostConstruct init() called!

删除spring.jpa.properties.javax.persistence.schema generation.*解决了这个问题。

我认为这是spring和hibernate版本的兼容性问题。我使用的是hibernate-core-5.2.10.Final.jar和hibernate-jpa-2.1-api-1.0.0.Final.jar。我没有为这两个JAR指定版本号。它们由Sping Boot 2.0.0.M2管理。