hadoop-2.6.0-src源码导入Eclipse 转载
转载地址:http://m.blog.csdn.net/blog/le119126/42009281
一.导入
先修改源码 参考 二.改错里面的第3条
1.cd到 hadoop-2.6.0-src/hadoop-maven-plugins
mvn intall
2.在cd到hadoop-2.6.0-src 目录下
mvn eclipse:eclipse -DskipTests
3. 在Eclipse中:File-Import-Existing Projects into Workspace 选择hadoop-2.6.0-src目录导入
二.改错
1./hadoop-common/src/test/java/org/apache/hadoop/io/serializer/avro/TestAvroSerialization.java显示找不到AvroRecord类
去http://grepcode.com/file/repo1.maven.org/maven2/org.apache.hadoop/hadoop-common/2.5.0/org/apache/hadoop/io/serializer/avro/AvroRecord.java/ 下载2.5.0或者更高版本的。放到相应位置
2.org.apache.hadoop.ipc 下面没有protobuf文件夹,也缺少相应的java文件,在org.apache.hadoop.ipc下面建立protobuf文件夹,把/hadoop-common/target/generated-sources/java/org/apache/hadoop/ipc/protobuf 里面的响应java文件移到该文件夹下-不要复制,复制会出现重复定义的错误。
3.hadoop-streaming里面的build path有问题,显示home/haodoop/桌面/hadoop-2.6.0-src/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/conf(missing)
我已经把所有源码文件已经导入到Eclipse 的工作目录workspace了,但是它指向的是桌面的源-我之前在 步骤一.导入 时用mvn install ;mvn eclipse:eclipse时的目录,根据网上说 右键hadoop-streaming项目-properties->左边Java Build Path->Source->选定错误项remove掉引用,当时好了,下次打开Eclipse还是有相同的问题。。我对java ,Eclipse不熟,下面是我的解决办法
解决:选中hadoop-streaming项目,在hadoop-stream目录下新建文件夹config,把hadoop-2.6.0-src/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/conf 中的文件拷贝到新建的config下,右键-properties->左边Java Build Path->Source->选定错误项 ,右边有edit
hadoop-streaming目录下的pom.xml文件,找到 :
<directory>${basedir}/../../hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/conf</directory>
修改为:
<directory>${basedir}/config</directory>
然后重新按照 一.导入中的步骤重新mvn intall,mvn eclipse:eclipse,再在Eclipse中删除掉有错的hadoop-streaming项目,然后再导入刚刚mvn生成的hadoop-streaming项目,发现 右键-properties->左边Java Build Path->Source 里面少了conf 出错的项,只有两项了,不放心就又用add Folder新建了一项