1. 程式人生 > >Maven編譯打包專案 mvn clean install 遇到的錯誤

Maven編譯打包專案 mvn clean install 遇到的錯誤

在進行Maven 編譯專案時執行命令:mvn  clean install遇到的問題:

[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
javac: ??Ч??Ŀ??汾?? 1.8
?÷?: javac <options> <source files>
-help ?????г????ܵ?ѡ??

[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.068 s
[INFO] Finished at: 2015-07-10T09:49:08+08:00
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project robot: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] javac: ??Ч??Ŀ??汾?? 1.8
[ERROR] ?÷?: javac <options> <source files>
[ERROR] -help ?????г????ܵ?ѡ??
[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
解決方案:

/etc/profile配置java的環境變數: 你的mvn 專案是用哪個版本的jdk. 就要配置那個版本的jdk.

我的配置如下:(根據你自己的JDK的位置:)

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home  (你自己的jdk的位置)
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
然後強制儲存檔案命令:

:w !sudo tee %

此時在進入專案執行:

$ git pull origin master

繼續mvn clean install;