解决:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin 命令行mvn打包的时候报错:No compiler is provided in this environment. Perhaps you are running on a JRE

这篇具有很好参考价值的文章主要介绍了解决:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin 命令行mvn打包的时候报错:No compiler is provided in this environment. Perhaps you are running on a JRE。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.mvn clean install -DskipTests; idea terminal 打包报错(用idea右边maven插件打包是没有问题的)。

解决:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
命令行mvn打包的时候报错:No compiler is provided in this environment. Perhaps you are running on a JRE

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time:  1.095 s

[INFO] Finished at: 2022-03-30T03:40:49+08:00

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project spiInterface: Compilation failure -> [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

2.开了-X,报错如下:

命令行mvn打包的时候报错:No compiler is provided in this environment. Perhaps you are running on a JRE

3.定位到根因,是jdk环境变量配置的问题

 默认的java_home 里面只有jre,所以无法编译。

我的mac有两个版本的java 1.8.0.311和1.8.0.312,这里默认配置1.8识别到的是前者

export JAVA_8_HOME="$(/usr/libexec/java_home -v 1.8)"
export JAVA_17_HOME="$(/usr/libexec/java_home -v 17)"

#默认设为JDK1.8
export JAVA_HOME=$JAVA_8_HOME

#alias命令动态切换JDK版本
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk17="export JAVA_HOME=$JAVA_17_HOME"
xukunpeng@192 ~ % java -version 
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode)

4.所以修改配置如下,地址更新到下面这个:

解决:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
命令行mvn打包的时候报错:No compiler is provided in this environment. Perhaps you are running on a JRE

5.source ~/.bash_profile 一下 ,让其生效

xukunpeng@192 ~ % java -version                                                                                        
openjdk version "1.8.0_312"
OpenJDK Runtime Environment Corretto-8.312.07.1 (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM Corretto-8.312.07.1 (build 25.312-b07, mixed mode)

7.restart idea,必要步骤

  解决:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
命令行mvn打包的时候报错:No compiler is provided in this environment. Perhaps you are running on a JRE

8.mvn clean install -DskipTests;  不出意外的build成功。

 解决:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
命令行mvn打包的时候报错:No compiler is provided in this environment. Perhaps you are running on a JRE

 文章来源地址https://www.toymoban.com/news/detail-481558.html

到了这里,关于解决:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin 命令行mvn打包的时候报错:No compiler is provided in this environment. Perhaps you are running on a JRE的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包