我将Sping Boot从1.5.3升级到2.0.0.M2。现在,即使使用spring.jpa.hibernate.ddl-auto = create,hibernate也不会创建表。它在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!
答案 0 :(得分:0)
删除spring.jpa.properties.javax.persistence.schema-generation.*
可以解决问题。