0

I am studying Hadoop on the book "Hadoop, the definitive guide 4th edition" by O'Really and I am having an issue in trying to create a Maven project for MRUnit testing. I just created the pom.xml file as shown in the book (just changing my hadoop version) but it does not work and Eclipse swhow me a lot of ArtifactTransferExceptions.

My pom.xml looks like this:

<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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>TestUnitCounter</groupId>
   <artifactId>TestUnitCounter</artifactId>
   <version>4.0</version>
<properties>
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <hadoop.version>2.6.0</hadoop.version>
</properties>
<dependencies>
<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-client</artifactId>
    <version>${hadoop.version}</version>
</dependency>

<!-- Unit test artifacts -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.apache.mrunit</groupId>
    <artifactId>mrunit</artifactId>
    <version>1.1.0</version>
    <classifier>hadoop2</classifier>
    <scope>test</scope>
</dependency>

<!-- Hadoop test artifact for running mini clusters -->
<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-minicluster</artifactId>
    <version>${hadoop.version}</version>
    <scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>hadoop-examples</finalName>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.5</version>
        <configuration>
            <outputDirectory>${basedir}</outputDirectory>
        </configuration>
  </plugin>
</plugins>
</build>
</project>

May anybody tell me how to fix the problem and writing a correct pom.xml for this?

Thanks.

4

1 回答 1

2

You could try the below steps:

1) Remove all your failed downloads with the below command:

Unix Platforms

find ~/.m2  -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;

Windows Platform

cd %userprofile%\.m2\repository
for /r %i in (*.lastUpdated) do del %i

2) Now, right-click on your project in eclipse and choose Maven-> Update Dependencies (Select the check box Force Update of Snapshots/Releases), OK.

于 2015-02-14T09:17:50.653 回答