IllegalArgumentException:argument type mismatch

时间:2022-07-22
本文章向大家介绍IllegalArgumentException:argument type mismatch,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Exception

nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'id' of 'class com.wzq.test.demo.entity.Fee' with value '1211518556674199553'Cause:java.lang.IllegalArgumentException: argument type mismatch

场景:

添加不传ID使用数据库中的自增。提示类型转换错误,Long转换Integer错误,原因ID初始化值过大转化成Integer错误。

解决:

设置ID的初始化值:ALTER TABLE TABLENAME AUTO_INCREMENT=1;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;