【问题标题】:Spring Data error: " HHH000389 Unsuccessful: drop table if exists"Spring Data 错误:“HHH000389 不成功:如果存在则删除表”
【发布时间】:2017-12-03 17:44:36
【问题描述】:

使用 Postgres 作为数据库和 Spring Boot + Spring Data 我正在尝试使用以下数据库配置属性以测试模式启动我的应用程序:

spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost/members
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.username=postgres
spring.datasource.password=password
spring.jpa.show-sql=true

我的表名为“会员”

当我第一次运行应用程序时,我可以看到表已创建。但是我不断收到以下错误:

2017-06-29 21:51:03.092 ERROR 1472 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000389: Unsuccessful: drop table member if exists
2017-06-29 21:51:03.093 ERROR 1472 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : ERROR: syntax error at or near "if"

【问题讨论】:

    标签: postgresql spring-boot spring-data


    【解决方案1】:

    在您的 application.properties 中,尝试添加以下内容:

    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect

    这可能有助于您的 ORM 使其语言适应您正在使用的数据库。

    干杯!

    【讨论】:

      【解决方案2】:

      我正在使用 H2 并且出现相同的错误“不成功:如果存在则删除表 xxx”。
      我尝试了所有的 dll-auto 和方言设置,但它不起作用。
      然后我在我的电脑主目录中找到了一个名为

      的文件

      test.mv.db

      其中“test”是我在 Spring 中为我的 H2 数据库设置的名称。
      如果我删除此文件,当我重新启动应用程序时一切正常。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-09-11
        • 2012-07-26
        • 2018-07-02
        • 1970-01-01
        • 2014-03-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多