在新增新的博客 即向t_blog添加第一条数据时 报错
[10501]SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value
could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement
参考百度 一位大佬的 https://jingyan.baidu.com/article/a24b33cdb2f19958ff002b3e.html
修改后仍然报这个错误
POJO
Blog.java中
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)// 不加这个的话 数据库中博客的id 就是从 18 19开始 而不是从1 开始
private Long id;//博客的id
设置了 GenerationType.IDENTITY 数据库中该字段仍然不是自增的 打开数据库表 勾选
修改后可成功添加数据