目录的输入与输出:
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>hadoop0</groupId>
<artifactId>hadoop0</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hadoop0</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hadoop.version>2.6.0</hadoop.version>
<jdiff.version>1.0.9</jdiff.version>
<remote.home>/root</remote.home>
<remote.host>IP马赛克</remote.host>
<remote.username>账户马赛克</remote.username>
<remote.password>密码马赛克</remote.password>
<bas.dir>./</bas.dir>
<dist.dir>${bas.dir}/target/</dist.dir>
<jar.name>WordCount</jar.name>
<jar.file>${jar.name}.jar</jar.file>
<remote.dir>${remote.home}</remote.dir>
<main.class>hadoop0.hadoop0.WordCount</main.class>
<outpath1>/input/wc.txt</outpath1>
<outpath2>/output/wc4</outpath2>
<hadoop.conf>-D mapreduce.map.java.opts=-Xmx2048m -D mapreduce.input.fileinputformat.split.minsize=1 -Dmapreduce.input.fileinputformat.split.maxsize=512000000 -D mapred.linerecordreader.maxlength=32768</hadoop.conf>
<ssh.cmd>source ${remote.home}/.bashrc;/root/hadoop-2.6.0/bin/hadoop jar ${remote.dir}/${jar.file} ${hadoop.conf} ${outpath1} ${outpath2}</ssh.cmd>
</properties>
<build>
<finalName>${jar.name}</finalName>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>root/</classpathPrefix>
<mainClass>${main.class}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- //sss -->
<plugin>
<inherited>false</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>test</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="a-test"
description="how to get antrun plugin to work with SCP and SSH">
<echo message="Remember to fill empty fields..." />
file to be transferred
<scp trust="true" failοnerrοr="true" verbose="off" sftp="true"
file="${dist.dir}/${jar.file}"
todir="${remote.username}:${remote.password}@${remote.host}:${remote.dir}/${jar.file}" />
calls deploy script
<sshexec host="${remote.host}" trust="yes"
username="${remote.username}" password="${remote.password}"
command="bash -c '${ssh.cmd}'" />
SSH
<taskdef name="sshexec"
classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec"
classpathref="maven.plugin.classpath" />
<taskdef name="scp"
classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp">
<classpath refid="maven.plugin.classpath" />
</taskdef>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-ant-tasks</artifactId>
<version>2.0.9</version>
</dependency>
</dependencies>
</project>
本地eclipse运行: