Can not set final java.lang.Class field org.apache.ibatis.binding.MapperProxy.mapperInterface to com

2023-08-10 08:18:58 浏览数 (1)

一、问题Can not set final java.lang.Class field

多数据源使用时,不能正确创建数据源连接。

java.lang.IllegalArgumentException: Can not set final java.lang.Class field org.apache.ibatis.binding.MapperProxy.mapperInterface to com.baomidou.mybatisplus.core.override.MybatisMapperProxy

代码语言:javascript复制
java.lang.IllegalArgumentException: Can not set final java.lang.Class field org.apache.ibatis.binding.MapperProxy.mapperInterface to com.baomidou.mybatisplus.core.override.MybatisMapperProxy

at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)
at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(UnsafeQualifiedObjectFieldAccessorImpl.java:38)
at java.lang.reflect.Field.get(Field.java:393)
at com.baomidou.dynamic.datasource.DynamicDataSourceClassResolver.targetClass(DynamicDataSourceClassResolver.java:62)
at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.determineDatasource(DynamicDataSourceAnnotationInterceptor.java:59)
at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.invoke(DynamicDataSourceAnnotationInterceptor.java:50)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy93.getOne(Unknown Source)
at com.common.templatemybatisplus.TemplateMybatisplusApplicationTests.test04(Templ

二、问题解决

版本太低,升级版本既可。

Github连接:

代码语言:javascript复制
https://github.com/baomidou/dynamic-datasource-spring-boot-starter/issues/106
代码语言:javascript复制
<dependency>
  <groupId>com.baomidou</groupId>
  <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
  <version>2.5.6</version>
</dependency>

0 人点赞