【问题标题】:spring.jpa.hibernate.ddl-auto= create does not create tables in Spring Boot 2.0.0.M2spring.jpa.hibernate.ddl-auto= create 在 Spring Boot 2.0.0.M2 中不创建表
【发布时间】:2017-12-25 20:16:56
【问题描述】:

我将 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!

【问题讨论】:

  • 我认为这是 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 管理。

标签: hibernate spring-boot spring-data-jpa


【解决方案1】:

删除spring.jpa.properties.javax.persistence.schema-generation.* 可以解决问题。

【讨论】:

    猜你喜欢
    • 2023-03-28
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    • 2017-12-29
    • 2015-12-15
    • 1970-01-01
    • 2017-11-30
    • 2018-09-16
    相关资源
    最近更新 更多