[英]spring.jpa.hibernate.ddl-auto=update not working in spring boot
[英]spring.jpa.hibernate.ddl-auto=update mariadb can not auto create Database indexes or Foreign key or column
1.弹簧靴
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
一切正常
怎么解决
发现问题,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'
一切都好 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.