找到了接口org.apache.hadoop.mapreduce.TaskAttemptContext,但是在mapreduce中出现类错误

时间:2018-12-13 06:28:29

标签: hadoop mapreduce

我是新来的hadoop。 我正在编写将文本文件转换为PDF的mapreduce代码,但出现上述错误。 在网上搜索问题后,我发现问题是org.apache.hadoop.mapreduce.TaskAttemptContext是Hadoop 1中的类,但成为Hadoop 2中的接口。但是,我在哪里都找不到解决方法。请帮助我解决这个问题。

我的POM中的依赖项是:

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <version>1.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>2.7.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>3.1.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itextpdf</artifactId>
            <version>5.0.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-mapreduce-client-core -->
        <dependency>
            <groupId>org.apache.mrunit</groupId>
            <artifactId>mrunit</artifactId>
            <version>1.1.0</version>
            <classifier>hadoop2</classifier>
        </dependency>

1 个答案:

答案 0 :(得分:0)

仅使用以下与hadoop相关的依赖项来避免“找到接口但期望类”错误:

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-common</artifactId>
    <version>3.2.0</version>
</dependency>
<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-mapreduce-client-core</artifactId>
    <version>3.2.0</version>
</dependency>