插入报错org.apache.ibatis.reflection.ReflectionException: Could not set property ‘id‘ of ‘class

报错:

exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'id' of 'class top.weimumu.loginapi.entity.CircleLikeEntity' with value '1232274629041627138' Cause: java.lang.IllegalArgumentException: argument type mismatch] with root cause

java.lang.IllegalArgumentException: argument type mismatch
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]

背景分析:

我是用mybatis-plus直接insert的,但是insert过程中报错,然后报的是id有问题,后来我排查了一下数据库是int类型,实体我是

Integer类型

解决办法:将实体的 Integer 改成int类型即可

你是技术宅么?那就加入我们吧~本博主不一定长期在线,可以进群大家一起解决问题~

欢迎加入 CSDN技术交流群2:(点击即可加群)QQ群:456543087

               CSDN技术交流群(已满员):(点击即可加群)QQ群:681223095。  

商务合作@群主,谢谢!

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
"nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property"这个异常是MyBatis在设置属性时发生的反射异常。这个异常通常发生在设置属性值时传入的参数类型与属性类型不匹配的情况下。根据引用中的错误信息,异常是由于无法将值'1539102131662880769'赋给属性'id',导致反射异常。 为了解决这个问题,你可以检查变量类型是否正确。确保传入的参数类型与属性类型一致。另外,还可以检查是否在配置文件中正确设置了主键自增的方式,以确保在插入数据时能够正确生成主键值。引用中提到的配置可以尝试添加到MyBatis的配置文件中,确保使用数据库的主键自增方式。 如果仍然无法解决该问题,你可以查看其他相关资料,了解更多关于这个异常的处理方法,引用提供的文章可能会对你有所帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set propertyid‘ ...](https://blog.csdn.net/m0_45877477/article/details/125388756)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Mybatis报错: org.apache.ibatis.exceptions.PersistenceException解决办法](https://download.csdn.net/download/weixin_38524871/12828533)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值