使用openjdk17编译时报错:Fatal error compiling: 错误: 不支持发行版本 1.17

1.在linux环境下(docker镜像里面)使用如下命令编译打包时报错

mvn clean package -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< xxx.xxx:pero-xdd >----------------------
[INFO] Building pero-xdd 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ pero-xdd ---
[INFO] Deleting /build/pero-xdd/target
[INFO] 
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ pero-xdd ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 2 resources from src/main/resources to target/classes
[INFO] 
[INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ pero-xdd ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 15 source files with javac [debug release 17] to target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.359 s
[INFO] Finished at: 2023-11-17T12:18:09+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project pero-xdd: Fatal error compiling: error: release version 17 not supported -> [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/MojoExecutionException

 

2.反复排查,java -version正常,mvn -v正常。最后发现,没有javac命令...也就是说这个基础镜像里没有openjdk-devel的包,最后安装上该包后,可以正常编译

yum install -y java-17-openjdk-devel

 

posted @ 2023-11-17 19:08  wdgde  阅读(681)  评论(0编辑  收藏  举报