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

OpenJDK Maven 编译出错: package jdk.nashorn.internal.runtime.logging does not exist

前言

  • OpenJDK 1.8.0
  • Maven 3.8.5
  • TencentOS Server 3.1

错误信息

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project tour-common: Compilation failure: Compilation failure: 
[ERROR] /opt/tour-common/src/main/java/com/tour/common/utils/ElasticSearchClientUtil.java:[6,44] package jdk.nashorn.internal.runtime.logging does not exist
[ERROR] /opt/tour-common/src/main/java/com/tour/common/utils/ElasticSearchClientUtil.java:[39,2] cannot find symbol
[ERROR]   symbol: class Logger
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :tour-common

分析

缺少 jdk.nashorn.internal.runtime.logging

情况1

OpenJDK中没有nashorn.jar。
jdk.nashorn.internal.runtime.loggingnashorn.jar 中。

解决办法:安装jdk1.8,从jdk的安装目录中找到 nashorn.jar 拷贝到OpenJDK的对应位置。
nashorn.jar%JAVA_HOME%\jre\lib\ext目录。

情况2

JDK的高版本中移除了 nashorn.jar

解决办法:降低版本到jdk1.8。

maven 操作

查看maven使用哪个JDK

shell> mvn -v
Apache Maven 3.8.5 (Red Hat 3.8.5-3)
Maven home: /usr/share/maven
Java version: 17.0.7, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-17-openjdk-17.0.7.0.7-3.tl3.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.119-19-0009.11", arch: "amd64", family: "unix"

查看JAVA_HOME

shell> echo $JAVA_HOME

设置JAVA_HOME

参考这里。

临时设置JAVA_HOME

shell> export JAVA_HOME=/usr/lib/jvm/TencentKona-8.0.12-352

找到java安装目录

shell> which java
/usr/bin/java
shell> ll /usr/bin/java
lrwxrwxrwx 1 root root 22 Sep 21  2022 /usr/bin/java -> /etc/alternatives/java
shell> ll /etc/alternatives/java
lrwxrwxrwx 1 root root 48 Oct 31  2022 /etc/alternatives/java -> /usr/lib/jvm/TencentKona-8.0.12-352/jre/bin/java
shell> cd /usr/lib/jvm/TencentKona-8.0.12-352
shell> ll
total 51564
-r--r--r--  1 root root     1522 Oct 21  2022 ASSEMBLY_EXCEPTION
drwxr-xr-x  2 root root     4096 Oct 31  2022 bin
drwxr-xr-x  9 root root     4096 Oct 31  2022 demo
drwxr-xr-x  3 root root     4096 Oct 31  2022 include
drwxr-xr-x  4 root root     4096 Oct 31  2022 jre
drwxr-xr-x  3 root root     4096 Oct 31  2022 lib
-r--r--r--  1 root root    19274 Oct 21  2022 LICENSE
drwxr-xr-x  4 root root     4096 Oct 31  2022 man
-rw-r--r--  1 root root       84 Oct 21  2022 release
drwxr-xr-x 10 root root     4096 Oct 31  2022 sample
-rw-r--r--  1 root root 52581093 Oct 21  2022 src.zip
-r--r--r--  1 root root   157063 Oct 21  2022 THIRD_PARTY_README

TencentOS Server 3.1 自带OpenJDK

TencentOS Server 3.1 中带2个OpenJDK

  • openjdk version “1.8.0_352”
  • openjdk 17.0.7 2023-04-18 LTS

切换jdk

设置JAVA_HOME即可

其它

https://blog.csdn.net/wlopper/article/details/119676442
https://blog.csdn.net/qq_36135928/article/details/120190807
https://stackoverflow.com/questions/59126867/jdk-nashorn-internal-ir-annotations-does-not-exist

http://www.lryc.cn/news/117376.html

相关文章:

  • .Net Framework请求外部Api
  • 线程池工作原理深入解析
  • chatGPT小白快速入门课程大纲
  • 网络编程——多路复用——epoll机制
  • chapter14:springboot与安全
  • Linux初识网络基础
  • vue3+ts 动态导入多文件组件
  • 补充122836356
  • 记录 pl-table 表格头部文字抖动的问题
  • Vite 创建 Vue项目之后,eslint 错误提示的处理
  • FFmpeg 硬编码VideoToolBox流程
  • 恒盛策略:内盘是买入还是卖出?
  • 安装Lombok--Lombok的常用注解说明及使用方法
  • 无涯教程-Perl - endpwent函数
  • vue项目在body设置公共的背景前提下,区分首页背景图和其他页面背景图
  • 测试人员该怎样写软件缺陷报告?
  • 【大数据】Flink 详解(二):核心篇 Ⅱ
  • 一孩半政策
  • 如何在 Spring Boot 中集成日志框架 SLF4J、Log4j
  • 如何在Linux布置nginx(附带Nginx基本操作步骤)
  • Xcode升级导致关联库报错
  • 利用docker run --rm 命令实现使用宿主机中没有的命令
  • 中级课程——XSS
  • win10+Vmware+ubuntu18 mosquitto调试记录
  • Java EE 突击 9 - Spring Boot 日志文件
  • 篇十六:命令模式:封装请求
  • Android 系统框架
  • 【Hystrix技术指南】(3)超时机制的原理和实现
  • MySQL: Failed to Connect to MySQL at XXXX:3306 with user root
  • 《大型网站技术架构设计》第二篇 架构-性能