首页 > 代码库 > eclipse导入hadoop 2.4
eclipse导入hadoop 2.4
使用以下命令安装Elicpse插件hadoop-maven-plugins:
$ cd ${HADOOP_HOME}/hadoop-maven-plugins
$ mvn install
然后生成Eclipse工程文件:
$ cd ${HADOOP_HOME}
$ mvn eclipse:eclipse -DskipTests
最后在Eclipse中按照以下流程导入源代码:“File” → “Import”→ “Existing Projects into Workspace”。
这里可以参考:http://www.aboutyun.com/thread-8211-1-1.html
下面是某个博客写的错误,其中我只遇到了几个,我在最后贴出我遇到的错误
Error#1. hadoop-streaming里面的build path有问题,显示/root/workspace/hadoop-2.2.0-src/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/conf(missing)
解决办法,remove掉引用就好。
Error#2. hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java中报sun.net.spi.nameservice.NameService错误,这是一个需要import的包,存在于openjdk中,在Oracle Jdk中没找到,需要下载一个。NameService是一个接口,在网上找一个NameService放到该包中就好。http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/sun/net/spi/nameservice/NameService.java#NameService
Error#3. /hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/XmlEditsVisitor.java里面显示
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
失败,这是由于Eclipse的强检查原则,打开Java -> Compiler -> Errors/Warnings and under "Deprecated and restricted API" change the setting of "Forbidden reference (access rules)" 将error级别调整到warning级别就好。
Error#4. /hadoop-common/src/test/java/org/apache/hadoop/io/serializer/avro/TestAvroSerialization.java显示没有AvroRecord类,在网上搜索到AvroRecord类放入到同级包中就行了。 http://grepcode.com/file/repo1.maven.org/maven2/org.apache.hadoop/hadoop-common/2.2.0/org/apache/hadoop/io/serializer/avro/AvroRecord.java#AvroRecord
Error#5. org.apache.hadoop.ipc.protobuf包是空的,需要在/hadoop-common/target/generated-sources/java中找到profobuf拷贝到/hadoop-common/src/test/java中就好了. 同时包里面还缺少了以下三个引用,在GrepCode上找一下,把hadoop-common2.2.0的相应文件下下来导入。
org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto;
org.apache.hadoop.ipc.protobuf.TestProtos.EchoResponseProto;
org.apache.hadoop.ipc.protobuf.TestRpcServiceProtos.TestProtobufRpcProto;
Error#6. /hadoop-auth/org/apache/hadoop/security/authentication/client/AuthenricatorTestCase.java中显示server.start()和server.stop()错误,还没找到原因所在,待检查~~~
-----------------------------------------分界线-------------------------------------------------
我遇到的错误提示56个,其实主要就3个问题
同上Error#1. hadoop-streaming里面的build path有问题,显示/root/workspace/hadoop-2.2.0-src/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/conf(missing)
解决办法,remove掉引用就好,具体右键右边出错项目->properties->左边Java Build Path->Source->选定错误项->右边Remove
同上Error#4,解决方法同上
同上Error#5,解决方法同上
然后应该就没错了
参考:
http://zhidao.baidu.com/link?url=HC-qIB_XxZ4ZdJtD-gPGI0mmWgE7fGpJC222Ri9hA-ju3iflCEr4IVt7ZogVOU7jYR4Fwew8YUp0opwo_9tdLZ4U-VD5DErkQn8OIhzZQfW