org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'id' of 'class com.zzy.web_practice.entity.Practice1' with value '1520304645107871746' Cause: java.lang.IllegalArgumentException: argument type mismatch
此异常为mybatis-plus异常
- mybatis-plus 在insert时会先检查映射属性,若有主键,则默认给主键赋值
- 若主键属性为integer,因为integer的最大值为2147483647,而mybatis生成的随机数远大于此值,例如:“1520304645107871746”
- 在insert的过程中给其赋值超出大小则抛出异常
- 解决办法
1.修改Integer 为 Long
2.将tableId 的type属性设置为自增(推荐)
@TableId(value = "id",type = IdType.AUTO)
private Integer id;