IllegalArgumentException: argument type mismatch 使用spring aop around方式 编程的时候报错....

本文分享了作者在使用Spring框架AOP时遇到的小问题,因参数类型转换导致的ArgumentTypeMismatch异常,通过修正参数类型,顺利执行了代理方法。避免类似错误,提高开发效率。

今天玩了下spring 框架的aop, 和各位大佬分享一下遇到的小bug, 写的不好还望见谅哈!

写了个demo案例,在测试类中进行;执行到了代理方法的时候报错了,当时就愣了!!!

在这里插入图片描述

然后我看到 他的报错中提示 argument type mismatch , 在下英语虽然烂,但是这几个单词还是勉强认出来了,原来是自己在aroung该参数的时候,不小心将原来的string 换成了 int 类型, spring 检查出来,并且给了我一个巴掌; 没事小问题, 将参数改回string ,正常aop 代理;

在这里插入图片描述
各位小伙伴们,这是小弟在spring aop 执行around方法遇到的错误, 别跟我才同样的坑哈!!!

Creating a new SqlSession SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5309ecfa] was not registered for synchronization because synchronization is not active JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@3598f6c9] will not be managed by Spring ==> Preparing: SELECT SEQ_COA_PPAT_DATA.NEXTVAL FROM DUAL ==> Parameters: <== Columns: NEXTVAL <== Row: 16 <== Total: 1 Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5309ecfa] Creating a new SqlSession Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1cf302d0] JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@3598f6c9] will be managed by Spring ==> Preparing: SELECT NATIVE_SYS_LOG.NEXTVAL FROM DUAL ==> Parameters: <== Columns: NEXTVAL <== Row: 4101 <== Total: 1 ==> Preparing: INSERT INTO SYS_LOGS ( ID, ADDRESS, REQUEST_BROWSER, EXCEPTION_DETAIL, LOG_TYPE, METHOD_NAME, METHOD_PARAMETERS, REQUEST_IP, USED_TIME, USER_NAME, CREATED_BY_WORKCODE, CREATED_TIME, CREATED_BY_COMPANY ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ==> Parameters: 4101(Long), 内网IP(String), Unknown(String), at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440) at com.sun.proxy.$Proxy82.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:271) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:60) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:96) at com.sun.proxy.$Proxy147.insert(Unknown Source) at com.baomidou.mybatisplus.extension.service.IService.save(IService.java:59) at com.smec.apps.coa.service.impl.CoaPpatDataServiceImpl.savePpatInitiate(CoaPpatDataServiceImpl.java:42) at com.smec.apps.coa.service.impl.CoaPpatDataServiceImpl$$FastClassBySpringCGLIB$$9757350c.invoke(<generated>) ...(String), ERROR(String), com.smec.apps.coa.controller.ppat.PPATInitiateController.savePpatInitiate()(String), { coaPpatData: CoaPpatData(id=16, caseNo=test, createdTime=20250725, department=null, createdByAccount=null, createdByCompany=null, materialNo=null, materialType=null, materialChineseName=null, materialEnglishName=null, vendorCode=null, vendorName=null, lavel=null, approver=null, email=null, createdByFab=null, status=null, version=null, pswTime=null, remark=null, supplierCode=null, createdByWorkcode=null, updatedByWorkcode=null, updatedTime=null, requestId=null, uuid=c152641e-9824-469e-8087-2c6bd2d81699, createdByOaId=null, site=null)}(String), 10.200.115.62(String), 0(Long), ME00545(String), ME00545(String), 2025-07-25 17:57:11.528(Timestamp), SX01(String) <== Updates: 1 Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1cf302d0] Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1cf302d0] Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1cf302d0] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1cf302d0] 2025-07-25 17:57:11.554 ERROR 45568 --- [nio-8000-exec-3] c.o.group.apps.core.aop.ConsolePrintAop : 抛出异常 : nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'updatedTime' of 'class com.smec.apps.coa.entity.CoaPpatData' with value '2025-07-25 17:57:11' Cause: java.lang.IllegalArgumentException: argument type mismatch 2025-07-25 17:57:11.560 ERROR 45568 --- [nio-8000-exec-3] c.o.g.a.c.c.e.Error500Controller : 捕获到错误: MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'updatedTime' of 'class com.smec.apps.coa.entity.CoaPpatData' with value '2025-07-25 17:57:11' Cause: java.lang.IllegalArgumentException: argument type mismatch Creating a new SqlSession
07-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值