SpringBoot 2.1.4
在使用Spring Data JPA時調用JpaRepository.save(Person)方法保存對象到mysql數據庫中的時報錯
java.sql.SQLSyntaxErrorException: Table 'test.hibernate_sequence' doesn't exist
解決方法
將@GeneratedValue改為@GeneratedValue(strategy=GenerationType.IDENTITY)解決問題
1 @Entity 2 public class Person { 3 @Id 4 @GeneratedValue 5 private Long id; 6 ... 7 }
1 @Entity 2 public class Person { 3 @Id 4 @GeneratedValue(strategy=GenerationType.IDENTITY) 5 private Long id; 6 ... 7 }