1)download eclipse



2)解压 eclipse



3)安装与配置 Ant 修 改 /etc/profile 文件



export ANT_HOME=[path]/apache-ant-1.7.1



export PATH=$PATH$:$ANT_HOME/bin



source /etc/profile






5)hadoop-2.0.0-cdh4.6.0/src/hadoop-mapreduce1-project/src/contrib/eclipse-plugin/build.properties



增加



eclipse.home=[path]/eclipse



reactor.repo=https://repository.cloudera.com/content/repositories/snapshots



version=2.0.0-cdh4.4.0



参考:http://stackoverflow.com/questions/18852338/ant-build-for-eclipse-cant-resolve-log4j 



否则会有提示:



[ivy:resolve]       :: commons-logging#commons-logging;1.1.1: several problems occurred while resolving dependency: commons-logging#commons-logging;1.1.1 {common=[default]}:
[ivy:resolve] reactor-repo: unable to get resource for commons-logging#commons-logging;1.1.1: res=${reactor.repo}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom: java.net.MalformedURLException: no protocol: ${reactor.repo}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
[ivy:resolve] several problems occurred while resolving dependency: org.apache.commons#commons-parent;5 {}:
[ivy:resolve] reactor-repo: unable to get resource for org/apache/commons#commons-parent;5: res=${reactor.repo}/org/apache/commons/commons-parent/5/commons-parent-5.pom: java.net.MalformedURLException: no protocol: ${reactor.repo}/org/apache/commons/commons-parent/5/commons-parent-5.pom
[ivy:resolve] several problems occurred while resolving dependency: org.apache#apache;4 {}:
[ivy:resolve] reactor-repo: unable to get resource for org/apache#apache;4: res=${reactor.repo}/org/apache/apache/4/apache-4.pom: java.net.MalformedURLException: no protocol: ${reactor.repo}/org/apache/apache/4/apache-4.pom
[ivy:resolve] reactor-repo: unable to get resource for org/apache#apache;4: res=${reactor.repo}/org/apache/apache/4/apache-4.jar: java.net.MalformedURLException: no protocol: ${reactor.repo}/org/apache/apache/4/apache-4.jar
[ivy:resolve] :: log4j#log4j;1.2.16: several problems occurred while resolving dependency: log4j#log4j;1.2.16 {common=[master]}:
[ivy:resolve] reactor-repo: unable to get resource for log4j#log4j;1.2.16: res=${reactor.repo}/log4j/log4j/1.2.16/log4j-1.2.16.pom: java.net.MalformedURLException: no protocol: ${reactor.repo}/log4j/log4j/1.2.16/log4j-1.2.16.pom
[ivy:resolve] reactor-repo: unable to get resource for log4j#log4j;1.2.16: res=${reactor.repo}/log4j/log4j/1.2.16/log4j-1.2.16.jar: java.net.MalformedURLException: no protocol: ${reactor.repo}/log4j/log4j/1.2.16/log4j-1.2.16.jar
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve]
[ivy:resolve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS





6)hadoop-2.0.0-cdh4.6.0/src/hadoop-mapreduce1-project/src/contrib/eclipse-plugin/build-contrib.xml



增加




<project name="hadoopbuildcontrib" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="eclipse.home"location="C:\eclipse"/> --添加部分
<property name="version" value="1.0.4"/> --添加部分
<property name="name" value="${ant.project.name}"/>
<property name="root" value="${basedir}"/>
<property name="hadoop.root" location="${root}/../../../"/>












7)修改${HADOOP_HOME}/src/contrib/eclipse-plugin/build.xml文件




<fileset dir="[path to lib of mapreduce1]">               --添加部分
直接全路径吧,这是示例:<fileset dir="./share/hadoop/mapreduce1/lib/">
<include name="hadoop*.jar"/> --添加部分
</fileset> --添加部分






注:如还有缺少,继续添加其他包的引入





8)hadoop-2.0.0-cdh4.6.0/src/hadoop-mapreduce1-project/src/contrib/eclipse-plugin目录下



ant jar



按提示有未定义的,再引入jar库





9)错误提示:case需要常量,修改如下文件



./src/hadoop-mapreduce1-project/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopJob.java





static JobState ofInt(int state) {



    switch (state) {



    //  case JobStatus.PREP:



     



       



    // 



     



       



    //  case JobStatus.FAILED:



     



       



    // 



     



       



     



       



    }   



 





10)编译通过后,在



hadoop-2.0.0-cdh4.6.0/src/hadoop-mapreduce1-project/build/contrib/eclipse-plugin



包含 hadoop-eclipse-plugin-2.0.0.jar 拷贝到eclipse的目录下重启elcipse







如果是yarn 框架的还是用新的mapre2的吧~~~~~