在用Spring-data-jpa添加數(shù)據(jù)庫數(shù)據(jù)的時候報錯Table 'xxx.hibernate_sequence' doesn't exist颅悉,這個是主鍵自增長策略問題嚣镜。
解決辦法
1激挪、在實體類的主鍵添加注解@GeneratedValue(strategy = GenerationType.IDENTITY)
@Entity
@Table(name = "user")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "username")
private String username;
}
2辰狡、
在application.properties配置文件中添加下列配置代碼:
spring.jpa.hibernate.use-new-id-generator-mappings=false