WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by

项目场景:

环境:
Java 版本:jdk13


问题描述:

运行时:此问题不是错误,但出现以下警告:
bug

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.ibatis.reflection.Reflector (file:/C:/Users/lenovo/.m2/repository/org/mybatis/mybatis/3.3.0/mybatis-3.3.0.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.apache.ibatis.reflection.Reflector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

原因分析:

在学习Mybatis框架的时候遇到这些警告,其原因是Mybatis版本与jdk版本的问题;使用jdk9及以上版本会出现以上问题:


解决方案:

解决方法:

  1. 使用jdk8及以下版本(并不推荐)
  2. 修改mybatis依赖(修改mybatis版本)

更改代码:

<dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.5.3</version>
</dependency>

解决后,警告消失:
bug


版权声明:本文为weixin_45048331原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。