对maven项目进行Maven install时报错,错误信息如下:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven-jar: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK
[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
分析原因
根据提示的错误信息,我们可以看出,该maven项目的环境是jre,而不是jdk环境,所以对maven项目进行maven install操作时,需要jdk环境。
解决
配置jdk环境。
Window—Java—Installed JREs—Add —选择Standard VM—选择本地的jdk目录。
然后,右键选择maven项目,将其jre环境换成jdk环境。
最后,右键选择maven项目,maven中点击update project,然后maven clean,install就可以了。