需要进一步学习hadoop、需要看看内部源码实现,因此需要将hadoop源码导入都eclipse中,简单总结一下,具体步骤如下:
首先确保已经安装了git、maven3、protobuf2.5、如果没有安装需要提前安装一下
1、下载hadoop源码
git clone git://git.apache.org/hadoop-common.git
2、进入hadoop-common目录,用maven生成eclipse工程
mvn install -DskipTests
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
3、导入Eclipse
导入Hadoop-Common
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-common-project目录为跟目录导入
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-assemblies目录为跟目录导入
导入HDFS
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-hdfs-project目录为跟目录导入
导入MapReduce
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-mapreduce-project目录为跟目录导入
导入YARN
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-yarn-project目录为跟目录导入
OK、全部导入成功,但是需要注意两个地方:
首先如果想hadoop-common全部编译成功,需要将hadoop-common的target/generate-test-source/java目录设置source folder
其次还得把JDK lib目录的tools.jar添加到classpath中。
配置好上面之后,所有代码都清晰可见
Hadoop源码导入Eclipse,布布扣,bubuko.com