简体   繁体   English

使用 Eclipse / Maven 构建 Hadoop - 缺少工件 jdk.tools:jdk.tools:jar:1.6

[英]Buiding Hadoop with Eclipse / Maven - Missing artifact jdk.tools:jdk.tools:jar:1.6

I am trying to import cloudera's org.apache.hadoop:hadoop-client:2.0.0-cdh4.0.0 from cdh4 maven repo in a maven project in eclipse 3.81, m2e plugin, with oracle's jdk 1.7.0_05 on win7 using我正在尝试从 cdh4 maven repo中导入 cloudera 的org.apache.hadoop:hadoop-client:2.0.0-cdh4.0.0在 eclipse 3.81 的 maven 项目中,m2e 插件,在 win7 上使用 oracle 的 jdk 1.7.0_05

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-client</artifactId>
    <version>2.0.0-cdh4.0.0</version>
</dependency>

however, I get the following error:但是,我收到以下错误:

The container 'Maven Dependencies' references non existing library 'C:\Users\MyUserId\.m2\repository\jdk\tools\jdk.tools\1.6\jdk.tools-1.6.jar'

more specific, maven states that the following artifact is missing更具体地说,maven 声明缺少以下工件

Missing artifact jdk.tools:jdk.tools:jar:1.6

How to solve this?如何解决这个问题?

The problem is in the Eclipse Maven support, the related question is here .问题出在 Eclipse Maven 支持中,相关问题在这里

Under Eclipse, the java.home variable is set to the JRE that was used to start Eclipse, not the build JRE.在 Eclipse 下, java.home变量设置为用于启动 Eclipse 的 JRE,而不是构建 JRE。 The default system JRE from C:\\Program Files doesn't include the JDK so tools.jar is not being found. C:\\Program Files中的默认系统 JRE 不包含 JDK,因此没有找到tools.jar

To fix the issue you need to start Eclipse using the JRE from the JDK by adding something like this to eclipse.ini ( before -vmargs !):要解决此问题,您需要使用 JDK 中的 JRE 启动 Eclipse,方法是在eclipse.ini-vmargs之前!)中添加类似内容:

-vm
C:/<your_path_to_jdk170>/jre/bin/server/jvm.dll

Then refresh the Maven dependencies (Alt-F5) (Just refreshing the project isn't sufficient).然后刷新 Maven 依赖项(Alt-F5)(仅仅刷新项目是不够的)。

jdk.tools:jdk.tools (or com.sun:tools , or whatever you name it) is a JAR file that is distributed with JDK. jdk.tools:jdk.tools (或com.sun:tools ,或任何您命名的名称)是随 JDK 分发的 JAR 文件。 Usually you add it to maven projects like this:通常你将它添加到 Maven 项目中,如下所示:

<dependency>
    <groupId>jdk.tools</groupId>
    <artifactId>jdk.tools</artifactId>
    <scope>system</scope>
    <systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>

See, the Maven FAQ for adding dependencies to tools.jar请参阅,将依赖项添加到tools.jarMaven 常见问题解答

Or, you can manually install tools.jar in the local repository using:或者,您可以使用以下命令在本地存储库中手动安装tools.jar

mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.6 -Dfile=tools.jar -DgeneratePom=true

and then reference it like Cloudera did, using:然后像 Cloudera 一样引用它,使用:

<dependency>
    <groupId>jdk.tools</groupId>
    <artifactId>jdk.tools</artifactId>
    <version>1.6</version>
</dependency>

thanks to npe, adding感谢npe,添加

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

to pom.xml did the trick.到 pom.xml 做到了。

If you can live without tools.jar and it's only included as a chained dependency, you can exclude it from the offending project:如果你可以没有 tools.jar 并且它只作为一个链接依赖被包含,你可以将它从有问题的项目中排除:

<dependency>
    <groupId>org.apache.ambari</groupId>
    <artifactId>ambari-metrics-common</artifactId>
    <version>2.1.0.0</version>
    <exclusions>
        <exclusion>
            <artifactId>jdk.tools</artifactId>
            <groupId>jdk.tools</groupId>
        </exclusion>
    </exclusions>
</dependency>

This worked for me:这对我有用:

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

I use below in my MR project.我在我的 MR 项目中使用了下面的内容。

<exclusions>
                <exclusion>
                    <artifactId>jdk.tools</artifactId>
                    <groupId>jdk.tools</groupId>
                </exclusion>
</exclusions>

maybe system install jdk package, but maybe some devel tools or plugin.也许系统安装了 jdk 包,但也许是一些开发工具或插件。

I find this problem under opensuse env.我在 opensuse env 下发现了这个问题。 and I install java-1_6_0-openjdk-devel我安装 java-1_6_0-openjdk-devel

the problem is disppeared..问题消失了..

I also faced this problem because I just only installed JRE not with JDK .我也遇到了这个问题,因为我只安装了JRE而不是JDK So , adding dependency for jdk.tools can't fix for me because tools.jar was not exist at my ${JAVA_HOME}/lib/ directory.因此,为jdk.tools添加依赖无法解决我的问题,因为我的${JAVA_HOME}/lib/目录中不存在tools.jar

Now I downloaded and installed JDK to fix it.现在我下载并安装了JDK来修复它。

Change the set of installed JREs in your eclipse.更改 Eclipse 中已安装的 JRE 集。 Window > Preferences > Java > Installed JREs, change the location of jre to %JAVA_HOME%/jre, but not something like C:\\Program Files\\Java\\jre7 Window > Preferences > Java > Installed JREs,将 jre 的位置更改为 %JAVA_HOME%/jre,但不是 C:\\Program Files\\Java\\jre7

If the jdk.tools is present in the .m2 repository.如果 jdk.tools 存在于 .m2 存储库中。 Still you get the error something like this:你仍然得到这样的错误:

missing artifact: jdk.tools.....c:.../jre/..缺少工件:jdk.tools.....c:.../jre/..

In the buildpath->configure build path-->Libraries.Just change JRE system library from JRE to JDK.在buildpath->configure build path-->Libraries中,将JRE系统库从JRE改为JDK即可。

try :尝试 :

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

also check : http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html还检查: http : //maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Ok, if you are using Windows OS好的,如果您使用的是 Windows 操作系统

  1. Go to C:\\Program Files\\Java\\jdk1.8.0_40\\lib (jdk Version might be different for you)转到 C:\\Program Files\\Java\\jdk1.8.0_40\\lib(jdk 版本可能因您而异)

  2. Make sure tools.jar is present (otherwise download it)确保 tools.jar 存在(否则下载)

  3. Copy this path "C:\\Program Files\\Java\\jdk1.8.0_40"复制这个路径“C:\\Program Files\\Java\\jdk1.8.0_40”

  4. In pom.xml在 pom.xml 中

    <dependency> <groupId>jdk.tools</groupId> <artifactId>jdk.tools</artifactId> <version>1.8.0_40</version> <scope>system</scope> <systemPath>C:/Program Files/Java/jdk1.8.0_40/lib/tools.jar</systemPath> </dependency>
  5. Rebuild and run!重建并运行! BINGO!答对了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM