方案一:
jdk.tools:jdk.tools是与JDK一起分发的一个JAR文件,可以如下方式加入到Maven项目中:
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7</version>
<scope>system</scope>
<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
详见Maven FAQ for adding dependencies to tools.jar
也可以在本地仓库中手动安装tools.jar,如下
mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.7 -Dfile=tools.jar -DgeneratePom=true
然后在pom.xml中添加:
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.6</version>
</dependency>
方案二:
D:\eclipse\workspace\logSystem>mvn dependency:tree
[INFO] +- org.apache.hadoop:hadoop-common:jar:2.4.1:compile
[INFO] | +- org.apache.hadoop:hadoop-annotations:jar:2.4.1:compile
[INFO] | | \- jdk.tools:jdk.tools:jar:1.7:system
[INFO] | +- org.apache.commons:commons-math3:jar:3.1.1:compile
[INFO] | +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] | +- commons-net:commons-net:jar:3.1:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | +- com.sun.jersey:jersey-json:jar:1.9:compile
[INFO] | | +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] | | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.8.3:compile
[INFO] | | \- org.codehaus.jackson:jackson-xc:jar:1.8.3:compile
找到:
[INFO] +- org.apache.hadoop:hadoop-common:jar:2.4.1:compile
[INFO] | +- org.apache.hadoop:hadoop-annotations:jar:2.4.1:compile
[INFO] | | \- jdk.tools:jdk.tools:jar:1.7:system
在pom.xml 找到 hadoop-common,增加:
<exclusions>
<exclusion>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
</exclusion>
</exclusions>