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
@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
一切都很正常
如何解决
答案 0 :(得分:0)
发现问题,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'
一切都好!