解決Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project autotest_fchtgl: Compilation failure的方法


在碰到maven install 發現報錯

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project autotest_fchtgl: 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

分析:

 對這個問題其實報錯中已經說的很清楚了,看第一條最后的 Perhaps you are running on a JRE rather than a JDK?

 就是說你可能編譯在一個JRE而不是JDK上,maven 編譯是要JDK的,可能你的編譯器配置了一個jre路徑。

解決:

 在eclipse中,選擇window→preference→java→Installed JREs 點add添加你的jdk路徑,選jdk而不是jre,之前的報錯原因就出在這里。

 

 然后右鍵你的maven工程,在maven中點擊update project,然后maven clean,install 一下就好了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM