Could not find artifact com.sun:tools:jar:1.5.0 問題解決java
標籤: toolsjarstrutsmavendependenciesjavaapache
2016-11-25 21:20 9892人閱讀 評論(5) 收藏 舉報app
分類:eclipse
【Eclipse】(8) maven
【maven package】,則依然報錯,但報的是另一個錯誤:
[INFO] Scanning for projects…[INFO]
[INFO] Building Struts 2 Blank Webapp 1.0-SNAPSHOT[INFO]
[INFO] BUILD FAILURE[INFO]
[INFO] Total time: 0.547s[INFO] Finished at: Wed Apr 13 13:09:48 CST 2011[INFO] Final Memory: 2M/4M[INFO]
[ERROR] Failed to execute goal on project my_struts: Could not resolve dependencies for project ricki.cheung.struts:my_struts:war:1.0-SNAPSHOT: Could not
find artifact com.sun:tools:jar:1.5.0 at specified path C:\Program Files\Java\jre1.6.0_01/../lib/tools.jar -> [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/DependencyResolutionExceptionui
後在網上查找解決方法,有外國網友說,在pom.xml添加以下依賴便可:
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>.net
不過,我試過仍是不行,另外一個外國網友說,把eclipse中的【Windows】-【Preferences】-【Java】-【Install JREs】改成JDK,而不用JRE,以下圖所示:
雖然我勾選了JDK,但仍是報錯,看了錯誤,發如今 C:\Program Files\Java\jre1.6.0_01/../lib/tools.jar沒法找到tools:jar,這讓我有點納悶了,明明已經選了使用JDK了,怎麼還去JRE那裏找呢,因而我把【Windows】-【Preferences】-【Java】-【Install JREs】中的JRE給remove掉,再次【maven package】就OK了。debug