cannot resolve jdk.tools:jdk.tools:jar:1.6

現(xiàn)象

maven編譯項(xiàng)目時(shí)報(bào)cannot resolve jdk.tools:jdk.tools:jar:1.6錯(cuò)誤。而pom.xml中沒(méi)有引用jdk.tools。
jdk.tools:jdk.tools (or com.sun:tools, or whatever you name it) is a JAR file that is distributed with JDK.

解決方式一

  • 手工安裝tools.jar到本地倉(cāng)庫(kù)
    mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.6 -Dfile=tools.jar -DgeneratePom=true
  • 在pom.xml中引用
<dependency>
    <groupId>jdk.tools</groupId>
    <artifactId>jdk.tools</artifactId>
    <scope>system</scope>
    <systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>

解決方式二

檢查環(huán)境變量是否配全。windows通過(guò)msi安裝完jdk后,雖然java -version可以執(zhí)行,但仍需配置環(huán)境變量。

JAVA_HOME=D:\Program Files\jdk
JRE_HOME=%JAVA_HOME%\jre
CLASS_PATH=%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%JRE_HOME%\lib
PATH=%PATH%;%JAVA_HOME%\bin;%JRE_HOME%\bin
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容