Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile

文章描述了在使用SpringBoot3.x时,因IDEA配置与系统环境JDK版本不一致导致编译错误的问题,提出了解决方案,包括检查系统环境、配置多个JDK环境并切换以及在.bash_profile中的alias设置。
摘要由CSDN通过智能技术生成

问题现象

使用SpringBoot3.x,Idea中maven、项目均配置了JDK17+环境、,控制台执行打包命令mvn -Dmaven.test.skip=true -U clean install 报如下错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.12.0:compile (default-compile) on project chen-engine: Fatal error compiling: 无效记: --release -> [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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :chen-engine

解决方案

mac环境,windows环境方案一样,切换环境即可

针对我的电脑(JDK8 和JDK17共存),因为环境不匹配问题,idea配置只是针对当前项目的配置,当你打开控制台的时候,控制台用的是系统的环境配置(我的电脑默认启用的是JDK8),控制台如下命令检查你的当前系统环境mvn -v

>  mvn -v        
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: /Users/chen/develop/gradle/apache-maven-3.6.1
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

此时将jdk8 切换至jdk17即可 执行命令jdk17(见下方JDK多环境配置)

> jdk17

再次执行打包命令mvn -Dmaven.test.skip=true -U clean install 即可

mac环境jdk17 命令配置

打开配置文件:sudo vim ~/.bash_profile,配置jdk17

JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home
JAVA_17_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
# 默认使用java8
export JAVA_HOME=$JAVA_8_HOME
export PATH="$JAVA_HOME:$PATH"

#alias jdk 配置此处,可以在控制台通过 jdk8、jdk17切换jdk版本呢
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk17="export JAVA_HOME=$JAVA_17_HOME"
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值