当前位置: 首页 > news >正文

使用高版本JDK编译低版本代码

背景

SonarQube运行于Java17,使用Sonar的Maven插件编译时,如果编译使用的JDK版本低于SonarQube使用的Java17,则会提示Java文件不匹配问题。

Error during SonarScanner execution
java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

maven-compiler-plugin

通过设置编译插件配置来输出指定版本的编译。

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><fork>true</fork><source>1.8</source><compilerVersion>1.8</compilerVersion><target>1.8</target><encoding>UTF-8</encoding></configuration>
</plugin>

当缺少上面的configuration配置时,可能出现编译报错。

Fatal error compiling: java.lang.ExceptionInInitializerError: Unable to make field private com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors com.sun.tools.javac.processing.JavacProcessingEnvironment.discoveredProcs accessible: module jdk.compiler does not “opens com.sun.tools.javac.processing” to unnamed module

JDK对应的Class File版本信息

JDK版本Class File版本
1.0.245
1.145
1.246
1.347
1.448
5.049
650
751
852
953
1054
1155
1256
1357
1458
1559
1660
1761
1862
1963
2064
2165
http://www.lryc.cn/news/276152.html

相关文章:

  • Zuul相关问题及到案(2024)
  • 【CSS】讲一讲BFC、IFC、GFC、FFC
  • 阶段十-分布式-任务调度
  • Godot4.2——爬虫小游戏简单制作
  • 对象的前世今生与和事佬(static)的故事
  • 报错curl: (6) Could not resolve host: raw.githubusercontent...的解决办法
  • 【基础篇】十二、引用计数法 可达性分析算法
  • C语言算法(二分查找、文件读写)
  • 流媒体学习之路(WebRTC)——Pacer与GCC(5)
  • 2023版本QT学习记录 -11- 多线程的使用(QT的方式)
  • iOS苹果和Android安卓测试APP应用程序的差异
  • 每日算法打卡:数的三次方根 day 7
  • 人机交互主板定制_基于MT8735安卓核心板的自助查询机方案
  • 全志F1C100s Linux 系统编译出错:不能连接 github
  • 如何保障 MySQL 和 Redis 的数据一致性?
  • Leetcode 2999. Count the Number of Powerful Integers
  • 【Reading Notes】(2)
  • 【设计模式之美】SOLID 原则之一:怎么才算是单一原则、如何取舍单一原则
  • # [NOIP2015 普及组] 扫雷游戏#洛谷
  • Unity中Shader的_Time精度问题
  • 听GPT 讲Rust源代码--compiler(15)
  • 关键字联合体union的定义和使用
  • 基于GA-PSO遗传粒子群混合优化算法的VRPTW问题求解matlab仿真
  • 【leetcode100-033】【链表】排序链表
  • [Kubernetes]5. k8s集群StatefulSet详解,以及数据持久化(SC PV PVC)
  • 数据库系统-甘晴void学习笔记
  • Azure Machine Learning - 人脸识别任务概述与技术实战
  • 强化学习的数学原理学习笔记 - 蒙特卡洛方法(Monte Carlo)
  • DDIA 第十一章:流处理
  • webpack知识点总结(高级应用篇)