hadoop:级联2.5.1和Hadoop2.2.0的文件拷贝

uqdfh47h  于 2021-06-04  发布在  Hadoop
关注(0)|答案(1)|浏览(381)

我最近在macosx上安装了一个伪分布式hadoop2.2.0集群。然后,我使用级联2.5.1尝试了基本的级联文件副本,但是当我使用maven编译项目时,出现了以下错误:

[ERROR] /Users/david/IdeaProjects//CascadingIntro/src/main/java/com/example/CascadingIntro.java:[24,24] 
cannot access org.apache.hadoop.mapred.JobConf
class file for org.apache.hadoop.mapred.JobConf not found

我做错了什么?我该如何解决这个问题?我相信cascading 2.5.1与hadoop2.2.0是兼容的。
我的pom.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<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>CascadingIntro</groupId>
<artifactId>CascadingIntro</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
    <repository>
        <id>conjars.org</id>
        <url>http://conjars.org/repo</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>cascading</groupId>
        <artifactId>cascading-core</artifactId>
        <version>2.5.1</version>
    </dependency>
    <dependency>
        <groupId>cascading</groupId>
        <artifactId>cascading-hadoop</artifactId>
        <version>2.5.1</version>
    </dependency>
</dependencies>
<build>
    <finalName>CascadingIntro</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</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.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.example.CascadingIntro</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

在我的卡斯卡迪金特罗课上:

package com.example;

import cascading.flow.FlowDef;
import cascading.flow.hadoop.HadoopFlowConnector;
import cascading.pipe.Pipe;
import cascading.property.AppProps;
import cascading.scheme.hadoop.TextDelimited;
import cascading.tap.Tap;
import cascading.tap.hadoop.Hfs;

import java.util.Properties;

public class CascadingIntro {

    public static void main(String[] args) {

        Properties properties = new Properties();
        AppProps.setApplicationJarClass( properties, CascadingIntro.class );

        HadoopFlowConnector flowConnector = new HadoopFlowConnector( properties );

        String inputPath = args[0];
        Tap inputTap = new Hfs(new TextDelimited(true,"\t"), inputPath);

        String outputPath = args[1];
        Tap outputTap = new Hfs(new TextDelimited(true,"\t"),outputPath);

        Pipe copyPipe = new Pipe("copy");

        FlowDef flowDef = FlowDef
            .flowDef()
            .addSource(copyPipe,inputTap)
            .addTailSink(copyPipe,outputTap);

        flowConnector.connect(flowDef).complete();
    }
}
9fkzdhlc

9fkzdhlc1#

您需要将hadoop客户端添加到依赖项:

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-client</artifactId>
    <version>2.2.0</version>
</dependency>

相关问题