最近遇到一个问题,本地调试代码没问题提交部署有问题。只能吧错误日志打印出来看看发现问题如下

系统内部错误: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database. Cause: java.lang.reflect.InaccessibleObjectException:
 Unable to make public int java.util.Arrays$ArrayList.size() accessible:
 module java.base does not "opens java.util" to unnamed module @44e81672 ### Cause: java.lang.reflect.InaccessibleObjectException:
 Unable to make public int java.util.Arrays$ArrayList.size() accessible: 
 module java.base does not "opens java.util" to unnamed module @44e81672 org.mybatis.spring.MyBatisSystemException:
 nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.
 Cause: java.lang.reflect.InaccessibleObjectException: Unable to make public int java.util.Arrays$ArrayList.size() accessible:
 module java.base does not "opens java.util" to unnamed module
 @44e81672 ### Cause: java.lang.reflect.InaccessibleObjectException: 
 Unable to make public int java.util.Arrays$ArrayList.size()
 accessible: module java.base does not "opens java.util" to unnamed module @44e81672 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:78)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
 at jdk.proxy2/jdk.proxy2.$Proxy93.selectList(Unknown Source) 
 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:158)
 at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:76)
 at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:61)

发现是mybatis方法,经过一通查发现可能是jdk版本的问题遂给本地代码切换了jdk版本原先是1.8,改为17,成功引出问题。

问题根源

看来是mybatis和jdk17组合出问题了,继续查mybatis

https://github.com/mybatis/mybatis-3/issues/2383

解决方案

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐