完整报错:
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into tbl_activity (id,owner,name,startDate,endDate,cost,description,createTime,createBy) values (?,?,?,?,?,?,?,?,?)
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null
控制台显示的sql语句:
2021-12-28 12:33:57,402 [http-nio-8080-exec-1] DEBUG [com.cyy.crm.workbench.dao.ActivityDao.save] - ==> Preparing: insert into tbl_activity (id,owner,name,startDate,endDate,cost,description,createTime,createBy) values (?,?,?,?,?,?,?,?,?)
2021-12-28 12:33:57,403 [http-nio-8080-exec-1] DEBUG [com.cyy.crm.workbench.dao.ActivityDao.save] - ==> Parameters: null, null, null, null, null, null, null, null, null
前端通过ajax请求往后端发送数据,debug后端controller发现是可以正常接收数据的,
检查过mapper文件无数遍,小到连空格是否是中文了也检查过了,就是解决不了。
我开始尝试把id的主键约束去掉,发现可以正常insert,但是insert的所有属性值都为null
好端端的数据怎么会变成null呢???
茫然了好几天,还好看了一篇文章有了思路,既然后端、配置文件都没问题,会不会是前端的原因呢??
于是我查看了前端的ajax请求,人傻了
这参数压根没对上啊???还有一个#忘记加了,活该我收的数据都是null
当后端和配置文件没问题的时候记得去检查前端!!!!心疼浪费的这几天时间