好家伙,又到了修bug的环节,(深叹一口气)
好了,来看报错- <strong>2022-10-29 23:27:52.155 WARN 15068 --- [nio-8011-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1364, SQLState: HY000
- 2022-10-29 23:27:52.156 ERROR 15068 --- [nio-8011-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper : Field 'id' doesn't have a default value
- 2022-10-29 23:27:52.157 ERROR 15068 --- [nio-8011-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement] with root cause</strong>
复制代码 提取关键字眼;- <strong>Field 'id' doesn't have a default value</strong>
复制代码
去网上查了一圈,
发现是由于"id"属性没有勾选"自动递增"
我们去到数据库表的设置界面
(我用的MySQL)

说明:勾选①Auto Increment 必须先勾选 ②Prinmary Key否则会报错
①PRIMARY KEY 约束唯一标识数据库表中的每条记录。
主键必须包含唯一的值。
主键列不能包含 NULL 值。
每个表都应该有一个主键,并且每个表只能有一个主键。
②Auto-increment 会在新记录插入表中时生成一个唯一的数字,
正如它名称,一样它会自动增加
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |