missing artifact sun.jdk:tools:jar:1.6.0:system

2019-07-29 03:36发布

问题:

i m using a mac and saw this error in one of my pom file. i googled around and added the following section to the pom.xml:

<profiles>
    <profile>
      <id>osx</id>
      <activation>
        <os>
          <family>mac</family>
        </os>
      </activation>
      <properties>
        <toolsjar>${java.home}/../Classes/classes.jar</toolsjar>
      </properties>
    </profile>
  </profiles>

...
 <dependency>
   <groupId>com.sun</groupId>
   <artifactId>tools</artifactId>
   <version>1.6.0</version>
   <scope>system</scope>
   <systemPath>/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar</systemPath>
 </dependency>
    ...

then when i ran

mvn clean install -Posx

i still got the same error. please help!

回答1:

Use the below command to install tools.jar from your installed JDK location to maven repository.

$mvn install:install-file -DgroupId=sun.jdk -DartifactId=tools -Dpackaging=jar -Dversion=1.6 -Dfile="C:\Program Files\Java\jdk1.6.0_27\lib\tools.jar"

Note: Make sure that JDK installed path correct in the above command.



标签: maven pom.xml