1. 程式人生 > >eclipse的maven專案提示Missing artifact jdk.tools:jdk.tools:jar:1.7

eclipse的maven專案提示Missing artifact jdk.tools:jdk.tools:jar:1.7

eclipse的maven工程的pom檔案中有如下配置

  <plugins>
       ……
     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
          <encoding>UTF-8</encoding>
        </configuration>
     </plugin>
  </plugins>

但老是提示Missing artifact jdk.tools:jdk.tools:jar:1.7。從網上找了一下原因大多都說是工程maven找不到系統內的jdk1.7,根本原因是沒有指定javaw.exe的的位置導致的,具體解決方法有二種:

方法一:修改eclipse配置檔案

      找到eclipse的安裝路徑,在安裝路徑下找到eclipse.ini,將其檔案開啟,在檔案中找到“-vmargs”,在“-vmargs”之前新增下面程式碼

-vm
D:\tools\java\jdk1.7\jre\bin\server\jvm.dll

     其中 D:\tools\java\jdk1.7 替換成自己的JAVA_HOME路徑記錄。如圖:

     修改之後重啟eclipse或STS即可

方法二:直接在pom.xml中加上一個依賴專案

    在pom檔案中新增下面配置

<dependency> 
    <groupId>jdk.tools</groupId> 
    <artifactId>jdk.tools</artifactId>
    <version>1.7</version>
    <scope>system</scope>
    <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>