【问题标题】:spring.jpa.hibernate.ddl-auto=update mariadb can not auto create Database indexes or Foreign key or columnspring.jpa.hibernate.ddl-auto=更新 mariadb 不能自动创建数据库索引或外键或列
【发布时间】:2017-05-05 07:09:16
【问题描述】:

1.spring boot

spring-boot-gradle-plugin:1.4.2.RELEASE

2.gradle

 dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '1.1.8'
}

3.application.properties

spring.jpa.hibernate.ddl-auto=update

4.实体

    @Entity public class Users { @Id
    private int id;

    @Column(nullable = false,unique = true)
    private int userId;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }
}

Hibernate 不能自动创建数据库索引或外键或约束或添加列

但是,当

spring-boot-gradle-plugin:1.2.4.RELEASE

一切正常

如何解决

【问题讨论】:

    标签: java jpa gradle spring-boot create-table


    【解决方案1】:

    发现问题,mariadb版本太低

    compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '1.1.8'
    

    改成

    compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '1.5.6'
    

    一切正常!

    【讨论】:

      猜你喜欢
      • 2020-08-02
      • 2012-07-27
      • 1970-01-01
      • 1970-01-01
      • 2017-10-13
      • 2010-10-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多