ClassCastException: org.springframework.aop.framework.JdkDynamicAopProxy cannot be cast to com.baomidou.mybatisplus.core.override.MybatisMapperProxy #6191
描述bug现象
ClassCastException: org.springframework.aop.framework.JdkDynamicAopProxy cannot be cast to com.baomidou.mybatisplus.core.override.MybatisMapperProxy
提供完整堆栈日志(可选)
[http-nio-8389-exec-1] ERROR [dispatcherServlet]:175 - [Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: org.springframework.aop.framework.JdkDynamicAopProxy cannot be cast to com.baomidou.mybatisplus.core.override.MybatisMapperProxy] with root cause]
java.lang.ClassCastException: org.springframework.aop.framework.JdkDynamicAopProxy cannot be cast to com.baomidou.mybatisplus.core.override.MybatisMapperProxy
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.getSqlSessionFactory(ServiceImpl.java:90) ~[mybatis-plus-extension-3.5.4.jar:3.5.4]
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.executeBatch(ServiceImpl.java:271) ~[mybatis-plus-extension-3.5.4.jar:3.5.4]
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.updateBatchById(ServiceImpl.java:221) ~[mybatis-plus-extension-3.5.4.jar:3.5.4]
at com.baomidou.mybatisplus.extension.service.IService.updateBatchById(IService.java:265) ~[mybatis-plus-extension-3.5.4.jar:3.5.4]
提供问题复现工程(可选)
请尽量提供复现工程,减少大家排错的时间.
当前使用版本 3.5.4 当前环境信息 Java8 + Mysql5.7
描述bug现象 ClassCastException: org.springframework.aop.framework.JdkDynamicAopProxy cannot be cast to com.baomidou.mybatisplus.core.override.MybatisMapperProxy
提供问题复现步骤 在springboot2.7.18版本项目中使用Mybatis-pulus 3.5.4的版本过程中发现调用IService接口中提供的updateBatchById时发现报错,经排查发现其实现类ServiceImpl中getSqlSessionFactory方法在MybatisMapperProxy mybatisMapperProxy = (MybatisMapperProxy)Proxy.getInvocationHandler(this.baseMapper)这行时有问题,当把plus的版本降低到3.5.1时就没有了,期待后续可以修复下,谢谢!
提供完整堆栈日志(可选) [http-nio-8389-exec-1] ERROR [dispatcherServlet]:175 - [Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: org.springframework.aop.framework.JdkDynamicAopProxy cannot be cast to com.baomidou.mybatisplus.core.override.MybatisMapperProxy] with root cause] java.lang.ClassCastException: org.springframework.aop.framework.JdkDynamicAopProxy cannot be cast to com.baomidou.mybatisplus.core.override.MybatisMapperProxy at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.getSqlSessionFactory(ServiceImpl.java:90) ~[mybatis-plus-extension-3.5.4.jar:3.5.4] at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.executeBatch(ServiceImpl.java:271) ~[mybatis-plus-extension-3.5.4.jar:3.5.4] at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.updateBatchById(ServiceImpl.java:221) ~[mybatis-plus-extension-3.5.4.jar:3.5.4] at com.baomidou.mybatisplus.extension.service.IService.updateBatchById(IService.java:265) ~[mybatis-plus-extension-3.5.4.jar:3.5.4] 提供问题复现工程(可选) 请尽量提供复现工程,减少大家排错的时间.