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 can not auto create Database indexes or Foreign key or constraint or add column
but,when
spring-boot-gradle-plugin:1.2.4.RELEASE
everything is normal
How to solve
Found the problem, mariadb version is too low
change to
everything is OK !