springboot mysql 插入数据报错

应该怎么解决

  • 用的是mybatis-plus自带的insert方法,driver中两个属性有值,所有字段,除了主键id都可以为空。driver的id为空,数据库id自增

  • serviceImpl中这句报错

int result = driverEntityMapper.insert(driver);
  • org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
  • Error updating database. Cause: java.lang.IllegalArgumentException: non null key required
  • The error may exist in com/xxxx/mapper/DriverEntityMapper.java (best guess)
  • The error may involve com.xxx.mapper.DriverEntityMapper.insert
  • The error occurred while executing an update
  • Cause: java.lang.IllegalArgumentException: non null key required

参数异常,看下数据库和你的插入的实体对象。数据库中有哪些是必填的不能为空的,和你入参实体比较下。

driverEntityMapper.insert(driver);
driver变量有传入openid值吗?可以断点调试下