因爲最近公司人手增多,開發和部署已經逐步分離,爲了方便部署人員打包部署,開發人員也逐步告別經過在 Eclipse 中 export 打包的方式,而習慣了使用 maven 進行打包。java
在使用 mvn package 打包時,控制檯報出以下錯誤信息,打包失敗:web
[INFO] BUILD FAILURE [INFO]------------------------------------------------------------------------ [INFO] Total time: 3.993 s [INFO] Finished at:2015-07-21T16:34:14+08:00 [INFO] Final Memory: 8M/121M [INFO]------------------------------------------------------------------------ [ERROR] Failed to execute goalorg.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile)on project rumorsend_web: Fatal error compiling: tools.jar not found:C:\Program Files\Java\jre1.8.0_45\..\lib\tools.jar -> [Help 1] [ERROR] [ERROR] To see the full stack trace of theerrors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch toenable full debug logging. [ERROR] [ERROR] For more information about theerrors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
其中,最重要的錯誤信息顯然是apache
tools.jar notfound: C:\ProgramFiles\Java\jre1.8.0_45\..\lib\tools.jarmaven
拿這個信息各類搜索引擎搜了一下,獲得的結果基本都是須要須要修改 Java庫,由 jre 目錄改成 jdk 目錄,但是看來看去在 Eclipse 中都是圖-1所示的結果:ide
圖-1搜索引擎
而 jdk1.8.0_u45 在當時 install 時確實也指向都是 jdk 目錄,反反覆覆在這塊作了各類各樣的修改,結果在 mvn package 時仍是報出了一樣的錯誤,後來一想,maven 打包和 Java 編譯使用的 jdk 可能不一樣,因而發現果真如此,如圖-2所示:spa
圖-2debug
因而修改 maven 打包時使用的 jdk,再次 mvn package,終於出現了久違的orm
[INFO] BUILDSUCCESS
完。blog