Maven无法解决hadoop项目的依赖关系

时间:2014-05-14 10:06:32

标签: maven hadoop mapreduce

我想从hadoop本书构建示例项目,但我得到了#34;无法解决依赖项错误"。 这是构建期间的错误:

[INFO] Building Chapter 2: MapReduce 3.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.hadoop:hadoop-core:jar:0.23.10 is missing, no dependency information available
[WARNING] The POM for org.apache.hadoop:hadoop-test:jar:0.23.10 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Chapter 2: MapReduce .............................. FAILURE [1.409s]
[INFO] Hadoop: The Definitive Guide, Example Code ........ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.819s
[INFO] Finished at: Wed May 14 12:19:14 EEST 2014
[INFO] Final Memory: 6M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ch02: Could not resolve dependencies for project com.hadoopbook:ch02:jar:3.0: The following artifacts could not be resolved: org.apache.hadoop:hadoop-core:jar:0.23.10, org.apache.hadoop:hadoop-test:jar:0.23.10: Failure to find org.apache.hadoop:hadoop-core:jar:0.23.10 in https://repository.apache.org/content/repositories/releases/ was cached in the local repository, resolution will not be reattempted until the update interval of apache.releases has elapsed or updates are forced -> [Help 1]

这是我的ch02项目的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.hadoopbook</groupId>
    <artifactId>hadoop-meta</artifactId>
    <version>3.0</version>
    <relativePath>../hadoop-meta/pom.xml</relativePath>
  </parent>
  <groupId>com.hadoopbook</groupId>
  <artifactId>ch02</artifactId>
  <packaging>jar</packaging>
  <version>3.0</version>
  <name>Chapter 2: MapReduce</name>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-all</artifactId>
    </dependency>
  </dependencies>
</project>

任何想法如何使用maven构建此代码以及问题是什么? 感谢

2 个答案:

答案 0 :(得分:1)

发生的事情是,Maven无法在远程存储库中找到它所寻找的内容。因此当它到达Apache's Maven repository时,它只是找不到版本0.23.10 hadoop-test的资源。

问题<relativePath>../hadoop-meta/pom.xml</relativePath>中pom文件的第8行特别指示Maven查看hadoop-meta/pom.xml。在#48到#50行,您将看到hadoop-test存储库的规范:

<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-test</artifactId>
<version>${hadoop.version}</version>

${hadoop.version}是您在maven命令中指定的值,即0.23.10。 然后maven转到Apache repo并查找hadoop-test v0.23.10,这不存在。那么Maven就会崩溃。

现在,如果您使用了hadoop-test中存在的版本,或者您更改了pom文件,那么hadoop-test不是依赖项。

答案 1 :(得分:0)

我也有这个问题,原来是因为NetBeans在我的pom.xml文件中添加了一些东西。自上次成功部署以来,没有添加任何内容。