不多说,直接上干货!
如何在Maven官网下载历史版本
Eclipse下Maven新建项目、自动打依赖jar包(包含普通项目和Web项目)
Eclipse下Maven新建Web项目index.jsp报错完美解决(war包)
HBase 开发环境搭建(Eclipse\MyEclipse + Maven)
Zookeeper项目开发环境搭建(Eclipse\MyEclipse + Maven)
Hive项目开发环境搭建(Eclipse\MyEclipse + Maven)
MapReduce 开发环境搭建(Eclipse\MyEclipse + Maven)
Hadoop项目开发环境搭建(Eclipse\MyEclipse + Maven)
第一步:
第二步:
第三步:
第四步:
第五步:
第六步:
第七步:默认的
<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>zhouls.bigdata</groupId>
<artifactId>enterpriseMyHadoop</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>enterpriseMyHadoop</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
第八步:修改得到
<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>zhouls.bigdata.enterpriseMyHadoop</groupId>
<artifactId>enterpriseMyHadoop</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <name>test</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hadoop.version>2.6.0</hadoop.version>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>zhouls.bigdata.enterpriseMyHadoop.MyDriver</mainClass>
</transformer>
</transformers>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
第九步:写代码
WordCount.java
package zhouls.bigdata.enterpriseMyHadoop; import java.io.IOException;
import java.util.StringTokenizer; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
@SuppressWarnings("unused")// 屏蔽java编译中的一些警告信息
public class WordCount extends Configured implements Tool{ public static class TokenizerMapper extends
Mapper<Object, Text, Text, IntWritable>
//这个Mapper类是一个泛型类型,它有四个形参类型,分别指定map函数的输入键、输入值、输出键、输出值的类型。hadoop没有直接使用Java内嵌的类型,而是自己开发了一套可以优化网络序列化传输的基本类型。这些类型都在org.apache.hadoop.io包中。
//比如这个例子中的Object类型,适用于字段需要使用多种类型的时候,Text类型相当于Java中的String类型,IntWritable类型相当于Java中的Integer类型
{
//定义两个变量
private final static IntWritable one = new IntWritable(1);//这个1表示每个单词出现一次,map的输出value就是1.
private Text word = new Text(); public void map(Object key, Text value, Context context)
//context它是mapper的一个内部类,简单的说*接口是为了在map或是reduce任务中跟踪task的状态,很自然的MapContext就是记录了map执行的上下文,在mapper类中,这个context可以存储一些job conf的信息,比如job运行时参数等,我们可以在map函数中处理这个信息,这也是Hadoop中参数传递中一个很经典的例子,同时context作为了map和reduce执行中各个函数的一个桥梁,这个设计和Java web中的session对象、application对象很相似
//简单的说context对象保存了作业运行的上下文信息,比如:作业配置信息、InputSplit信息、任务ID等
//我们这里最直观的就是主要用到context的write方法。
throws IOException, InterruptedException {
//The tokenizer uses the default delimiter set, which is " \t\n\r": the space character, the tab character, the newline character, the carriage-return character
StringTokenizer itr = new StringTokenizer(value.toString());//将Text类型的value转化成字符串类型
//StringTokenizer是字符串分隔解析类型,StringTokenizer 用来分割字符串,你可以指定分隔符,比如',',或者空格之类的字符。
while (itr.hasMoreTokens()) {//hasMoreTokens() 方法是用来测试是否有此标记生成器的字符串可用更多的标记。
//java.util.StringTokenizer.hasMoreTokens()
word.set(itr.nextToken());//nextToken()这是 StringTokenizer 类下的一个方法,nextToken() 用于返回下一个匹配的字段。
context.write(word, one);
}
}
} public static class IntSumReducer extends
Reducer<Text, IntWritable, Text, IntWritable> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values,
Context context) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
}
} public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
//Configuration类代表作业的配置,该类会加载mapred-site.xml、hdfs-site.xml、core-site.xml等配置文件。
//删除已经存在的输出目录
Path mypath = new Path("hdfs://djt002:9000/outData/wordcount-out");//输出路径
FileSystem hdfs = mypath.getFileSystem(conf);//获取文件系统
//如果文件系统中存在这个输出路径,则删除掉,保证输出目录不能提前存在。
if (hdfs.isDirectory(mypath)) {
hdfs.delete(mypath, true);
}
//job对象指定了作业执行规范,可以用它来控制整个作业的运行。
Job job = Job.getInstance();// new Job(conf, "word count");
job.setJarByClass(WordCount.class);//我们在hadoop集群上运行作业的时候,要把代码打包成一个jar文件,然后把这个文件
//传到集群上,然后通过命令来执行这个作业,但是命令中不必指定JAR文件的名称,在这条命令中通过job对象的setJarByClass()
//中传递一个主类就行,hadoop会通过这个主类来查找包含它的JAR文件。 job.setMapperClass(TokenizerMapper.class);
//job.setReducerClass(IntSumReducer.class);
job.setCombinerClass(IntSumReducer.class); job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
//一般情况下mapper和reducer的输出的数据类型是一样的,所以我们用上面两条命令就行,如果不一样,我们就可以用下面两条命令单独指定mapper的输出key、value的数据类型
//job.setMapOutputKeyClass(Text.class);
//job.setMapOutputValueClass(IntWritable.class);
//hadoop默认的是TextInputFormat和TextOutputFormat,所以说我们这里可以不用配置。
//job.setInputFormatClass(TextInputFormat.class);
//job.setOutputFormatClass(TextOutputFormat.class); FileInputFormat.addInputPath(job, new Path(
"hdfs://djt002:9000/inputData/wordcount/wc.txt"));//FileInputFormat.addInputPath()指定的这个路径可以是单个文件、一个目录或符合特定文件模式的一系列文件。
//从方法名称可以看出,可以通过多次调用这个方法来实现多路径的输入。
FileOutputFormat.setOutputPath(job, new Path(
"hdfs://djt002:9000/outData/wordcount-out"));//只能有一个输出路径,该路径指定的就是reduce函数输出文件的写入目录。
//特别注意:输出目录不能提前存在,否则hadoop会报错并拒绝执行作业,这样做的目的是防止数据丢失,因为长时间运行的作业如果结果被意外覆盖掉,那肯定不是我们想要的
System.exit(job.waitForCompletion(true) ? 0 : 1);
//使用job.waitForCompletion()提交作业并等待执行完成,该方法返回一个boolean值,表示执行成功或者失败,这个布尔值被转换成程序退出代码0或1,该布尔参数还是一个详细标识,所以作业会把进度写到控制台。
//waitForCompletion()提交作业后,每秒会轮询作业的进度,如果发现和上次报告后有改变,就把进度报告到控制台,作业完成后,如果成功就显示作业计数器,如果失败则把导致作业失败的错误输出到控制台
} public int run(String[] args) throws Exception {
// TODO Auto-generated method stub
return 0;
}
} //TextInputFormat是hadoop默认的输入格式,这个类继承自FileInputFormat,使用这种输入格式,每个文件都会单独作为Map的输入,每行数据都会生成一条记录,每条记录会表示成<key,value>的形式。
//key的值是每条数据记录在数据分片中的字节偏移量,数据类型是LongWritable.
//value的值为每行的内容,数据类型为Text。
//
//实际上InputFormat()是用来生成可供Map处理的<key,value>的。
//InputSplit是hadoop中用来把输入数据传送给每个单独的Map(也就是我们常说的一个split对应一个Map),
//InputSplit存储的并非数据本身,而是一个分片长度和一个记录数据位置的数组。
//生成InputSplit的方法可以通过InputFormat()来设置。
//当数据传给Map时,Map会将输入分片传送给InputFormat(),InputFormat()则调用getRecordReader()生成RecordReader,RecordReader则再通过creatKey()和creatValue()创建可供Map处理的<key,value>对。
//
//OutputFormat()
//默认的输出格式为TextOutputFormat。它和默认输入格式类似,会将每条记录以一行的形式存入文本文件。它的键和值可以是任意形式的,因为程序内部会调用toString()将键和值转化为String类型再输出。
MyDriver.java
package zhouls.bigdata.enterpriseMyHadoop; import org.apache.hadoop.util.ProgramDriver;
/*
* 管理所有MapReduce 程序
*/
public class MyDriver {
public static void main(String argv[]){
int exitCode = -1;
ProgramDriver pgd = new ProgramDriver();
try {
pgd.addClass("wordcount", WordCount.class,
"A map/reduce program that counts the words in the input files."); exitCode = pgd.run(argv);
}
catch(Throwable e){
e.printStackTrace();
} System.exit(exitCode);
}
}
注意的是,在这里,我们可以随着以后的业务,添加。
pgd.addClass("wordcount1", WordCount1.class,
"A map/reduce program that counts the words in the input files.");
pgd.addClass("wordcount2", WordCount2.class,
"A map/reduce program that counts the words in the input files.");
....等
这里的wordcount1是WordCount1.class的别名。即比如我们打jar包到hadoop集群,在我们的任何路径下,执行
$HADOOP_HOME/bin/hadoop jar enterpriseMyHadoop-1.0-SNAPSHOT.jar wordcount1 hdfs://djt002:9000/inputData/wordcount/wc.txt hdfs://djt002:9000/outData/wordcount-out
enterpriseMyHadoop-1.0-SNAPSHOT.jar是我们打好的jar包名
wordcount1是我们的类的别名,即这样可以方便替代冗余的书写。
hdfs://djt002:9000/inputData/wordcount/wc.txt是输入路径
hdfs://djt002:9000/outData/wordcount-out是输出路径
第十步:打jar包
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>D:
D:\>cd D:\Code\MyEclipseJavaCode\enterpriseMyHadoop
D:\Code\MyEclipseJavaCode\enterpriseMyHadoop>mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ enterpriseMyHadoop ---
[INFO] Deleting D:\Code\MyEclipseJavaCode\enterpriseMyHadoop\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.509 s
[INFO] Finished at: 2017-03-10T16:50:56+08:00
[INFO] Final Memory: 6M/122M
[INFO] ------------------------------------------------------------------------
D:\Code\MyEclipseJavaCode\enterpriseMyHadoop>
D:\Code\MyEclipseJavaCode\enterpriseMyHadoop>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ enterprise
MyHadoop ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Code\MyEclipseJavaCode\enterpriseM
yHadoop\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ enterpriseMyHad
oop ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to D:\Code\MyEclipseJavaCode\enterpriseMyHadoop\
target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ en
terpriseMyHadoop ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Code\MyEclipseJavaCode\enterpriseM
yHadoop\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ enterpr
iseMyHadoop ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\Code\MyEclipseJavaCode\enterpriseMyHadoop\t
arget\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ enterpriseMyHadoop
---
[INFO] Surefire report directory: D:\Code\MyEclipseJavaCode\enterpriseMyHadoop\t
arget\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running zhouls.bigdata.enterpriseMyHadoop.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ enterpriseMyHadoop ---
[INFO] Building jar: D:\Code\MyEclipseJavaCode\enterpriseMyHadoop\target\enterpr
iseMyHadoop-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-shade-plugin:2.4.1:shade (default) @ enterpriseMyHadoop ---
[INFO] Including org.apache.hadoop:hadoop-common:jar:2.6.0 in the shaded jar.
[INFO] Including org.apache.hadoop:hadoop-annotations:jar:2.6.0 in the shaded ja
r.
[INFO] Including com.google.guava:guava:jar:11.0.2 in the shaded jar.
[INFO] Including commons-cli:commons-cli:jar:1.2 in the shaded jar.
[INFO] Including org.apache.commons:commons-math3:jar:3.1.1 in the shaded jar.
[INFO] Including xmlenc:xmlenc:jar:0.52 in the shaded jar.
[INFO] Including commons-httpclient:commons-httpclient:jar:3.1 in the shaded jar
.
[INFO] Including commons-codec:commons-codec:jar:1.4 in the shaded jar.
[INFO] Including commons-io:commons-io:jar:2.4 in the shaded jar.
[INFO] Including commons-net:commons-net:jar:3.1 in the shaded jar.
[INFO] Including commons-collections:commons-collections:jar:3.2.1 in the shaded
jar.
[INFO] Including javax.servlet:servlet-api:jar:2.5 in the shaded jar.
[INFO] Including org.mortbay.jetty:jetty:jar:6.1.26 in the shaded jar.
[INFO] Including org.mortbay.jetty:jetty-util:jar:6.1.26 in the shaded jar.
[INFO] Including com.sun.jersey:jersey-core:jar:1.9 in the shaded jar.
[INFO] Including com.sun.jersey:jersey-json:jar:1.9 in the shaded jar.
[INFO] Including org.codehaus.jettison:jettison:jar:1.1 in the shaded jar.
[INFO] Including com.sun.xml.bind:jaxb-impl:jar:2.2.3-1 in the shaded jar.
[INFO] Including javax.xml.bind:jaxb-api:jar:2.2.2 in the shaded jar.
[INFO] Including javax.xml.stream:stax-api:jar:1.0-2 in the shaded jar.
[INFO] Including javax.activation:activation:jar:1.1 in the shaded jar.
[INFO] Including org.codehaus.jackson:jackson-jaxrs:jar:1.8.3 in the shaded jar.
[INFO] Including org.codehaus.jackson:jackson-xc:jar:1.8.3 in the shaded jar.
[INFO] Including com.sun.jersey:jersey-server:jar:1.9 in the shaded jar.
[INFO] Including asm:asm:jar:3.1 in the shaded jar.
[INFO] Including tomcat:jasper-compiler:jar:5.5.23 in the shaded jar.
[INFO] Including tomcat:jasper-runtime:jar:5.5.23 in the shaded jar.
[INFO] Including javax.servlet.jsp:jsp-api:jar:2.1 in the shaded jar.
[INFO] Including commons-el:commons-el:jar:1.0 in the shaded jar.
[INFO] Including commons-logging:commons-logging:jar:1.1.3 in the shaded jar.
[INFO] Including log4j:log4j:jar:1.2.17 in the shaded jar.
[INFO] Including net.java.dev.jets3t:jets3t:jar:0.9.0 in the shaded jar.
[INFO] Including org.apache.httpcomponents:httpclient:jar:4.1.2 in the shaded ja
r.
[INFO] Including org.apache.httpcomponents:httpcore:jar:4.1.2 in the shaded jar.
[INFO] Including com.jamesmurty.utils:java-xmlbuilder:jar:0.4 in the shaded jar.
[INFO] Including commons-lang:commons-lang:jar:2.6 in the shaded jar.
[INFO] Including commons-configuration:commons-configuration:jar:1.6 in the shad
ed jar.
[INFO] Including commons-digester:commons-digester:jar:1.8 in the shaded jar.
[INFO] Including commons-beanutils:commons-beanutils:jar:1.7.0 in the shaded jar
.
[INFO] Including commons-beanutils:commons-beanutils-core:jar:1.8.0 in the shade
d jar.
[INFO] Including org.slf4j:slf4j-api:jar:1.7.5 in the shaded jar.
[INFO] Including org.slf4j:slf4j-log4j12:jar:1.7.5 in the shaded jar.
[INFO] Including org.codehaus.jackson:jackson-core-asl:jar:1.9.13 in the shaded
jar.
[INFO] Including org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13 in the shade
d jar.
[INFO] Including org.apache.avro:avro:jar:1.7.4 in the shaded jar.
[INFO] Including com.thoughtworks.paranamer:paranamer:jar:2.3 in the shaded jar.
[INFO] Including org.xerial.snappy:snappy-java:jar:1.0.4.1 in the shaded jar.
[INFO] Including com.google.protobuf:protobuf-java:jar:2.5.0 in the shaded jar.
[INFO] Including com.google.code.gson:gson:jar:2.2.4 in the shaded jar.
[INFO] Including org.apache.hadoop:hadoop-auth:jar:2.6.0 in the shaded jar.
[INFO] Including org.apache.directory.server:apacheds-kerberos-codec:jar:2.0.0-M
15 in the shaded jar.
[INFO] Including org.apache.directory.server:apacheds-i18n:jar:2.0.0-M15 in the
shaded jar.
[INFO] Including org.apache.directory.api:api-asn1-api:jar:1.0.0-M20 in the shad
ed jar.
[INFO] Including org.apache.directory.api:api-util:jar:1.0.0-M20 in the shaded j
ar.
[INFO] Including org.apache.curator:curator-framework:jar:2.6.0 in the shaded ja
r.
[INFO] Including com.jcraft:jsch:jar:0.1.42 in the shaded jar.
[INFO] Including org.apache.curator:curator-client:jar:2.6.0 in the shaded jar.
[INFO] Including org.apache.curator:curator-recipes:jar:2.6.0 in the shaded jar.
[INFO] Including com.google.code.findbugs:jsr305:jar:1.3.9 in the shaded jar.
[INFO] Including org.htrace:htrace-core:jar:3.0.4 in the shaded jar.
[INFO] Including org.apache.zookeeper:zookeeper:jar:3.4.6 in the shaded jar.
[INFO] Including org.apache.commons:commons-compress:jar:1.4.1 in the shaded jar
.
[INFO] Including org.tukaani:xz:jar:1.0 in the shaded jar.
[INFO] Including org.apache.hadoop:hadoop-hdfs:jar:2.6.0 in the shaded jar.
[INFO] Including commons-daemon:commons-daemon:jar:1.0.13 in the shaded jar.
[INFO] Including io.netty:netty:jar:3.6.2.Final in the shaded jar.
[INFO] Including xerces:xercesImpl:jar:2.9.1 in the shaded jar.
[INFO] Including xml-apis:xml-apis:jar:1.3.04 in the shaded jar.
[INFO] Including org.apache.hadoop:hadoop-client:jar:2.6.0 in the shaded jar.
[INFO] Including org.apache.hadoop:hadoop-mapreduce-client-app:jar:2.6.0 in the
shaded jar.
[INFO] Including org.apache.hadoop:hadoop-mapreduce-client-common:jar:2.6.0 in t
he shaded jar.
[INFO] Including org.apache.hadoop:hadoop-yarn-client:jar:2.6.0 in the shaded ja
r.
[INFO] Including org.apache.hadoop:hadoop-yarn-server-common:jar:2.6.0 in the sh
aded jar.
[INFO] Including org.apache.hadoop:hadoop-mapreduce-client-shuffle:jar:2.6.0 in
the shaded jar.
[INFO] Including org.fusesource.leveldbjni:leveldbjni-all:jar:1.8 in the shaded
jar.
[INFO] Including org.apache.hadoop:hadoop-yarn-api:jar:2.6.0 in the shaded jar.
[INFO] Including org.apache.hadoop:hadoop-mapreduce-client-core:jar:2.6.0 in the
shaded jar.
[INFO] Including org.apache.hadoop:hadoop-yarn-common:jar:2.6.0 in the shaded ja
r.
[INFO] Including com.sun.jersey:jersey-client:jar:1.9 in the shaded jar.
[INFO] Including org.apache.hadoop:hadoop-mapreduce-client-jobclient:jar:2.6.0 i
n the shaded jar.
[WARNING] hadoop-yarn-common-2.6.0.jar, hadoop-yarn-client-2.6.0.jar define 2 ov
erlapping classes:
[WARNING] - org.apache.hadoop.yarn.client.api.impl.package-info
[WARNING] - org.apache.hadoop.yarn.client.api.package-info
[WARNING] jasper-compiler-5.5.23.jar, jasper-runtime-5.5.23.jar define 1 overlap
ping classes:
[WARNING] - org.apache.jasper.compiler.Localizer
[WARNING] commons-beanutils-core-1.8.0.jar, commons-beanutils-1.7.0.jar, commons
-collections-3.2.1.jar define 10 overlapping classes:
[WARNING] - org.apache.commons.collections.FastHashMap$EntrySet
[WARNING] - org.apache.commons.collections.ArrayStack
[WARNING] - org.apache.commons.collections.FastHashMap$1
[WARNING] - org.apache.commons.collections.FastHashMap$KeySet
[WARNING] - org.apache.commons.collections.FastHashMap$CollectionView
[WARNING] - org.apache.commons.collections.BufferUnderflowException
[WARNING] - org.apache.commons.collections.Buffer
[WARNING] - org.apache.commons.collections.FastHashMap$CollectionView$Collecti
onViewIterator
[WARNING] - org.apache.commons.collections.FastHashMap$Values
[WARNING] - org.apache.commons.collections.FastHashMap
[WARNING] hadoop-yarn-common-2.6.0.jar, hadoop-yarn-api-2.6.0.jar define 3 overl
apping classes:
[WARNING] - org.apache.hadoop.yarn.factories.package-info
[WARNING] - org.apache.hadoop.yarn.util.package-info
[WARNING] - org.apache.hadoop.yarn.factory.providers.package-info
[WARNING] commons-beanutils-core-1.8.0.jar, commons-beanutils-1.7.0.jar define 8
2 overlapping classes:
[WARNING] - org.apache.commons.beanutils.WrapDynaBean
[WARNING] - org.apache.commons.beanutils.Converter
[WARNING] - org.apache.commons.beanutils.converters.IntegerConverter
[WARNING] - org.apache.commons.beanutils.locale.LocaleBeanUtilsBean
[WARNING] - org.apache.commons.beanutils.locale.converters.DecimalLocaleConver
ter
[WARNING] - org.apache.commons.beanutils.locale.converters.DoubleLocaleConvert
er
[WARNING] - org.apache.commons.beanutils.converters.ShortConverter
[WARNING] - org.apache.commons.beanutils.converters.StringArrayConverter
[WARNING] - org.apache.commons.beanutils.locale.LocaleConvertUtilsBean
[WARNING] - org.apache.commons.beanutils.LazyDynaClass
[WARNING] - 72 more...
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://docs.codehaus.org/display/MAVENUSER/Shade+Plugin
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing D:\Code\MyEclipseJavaCode\enterpriseMyHadoop\target\enterpriseM
yHadoop-1.0-SNAPSHOT.jar with D:\Code\MyEclipseJavaCode\enterpriseMyHadoop\targe
t\enterpriseMyHadoop-1.0-SNAPSHOT-shaded.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:17 min
[INFO] Finished at: 2017-03-10T16:55:33+08:00
[INFO] Final Memory: 40M/224M
[INFO] ------------------------------------------------------------------------
D:\Code\MyEclipseJavaCode\enterpriseMyHadoop>
之前是空的,没有
输入打包命令mvn package,变成如下,刷新一下MyEclipse的target目录
成功!
最后将jar包,传到hdoop或spark集群里,这里我不多赘述。