安装 Hadoop 的 Eclipse 插件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13782042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing Hadoop's Eclipse Plugin
提问by user1888243
I have such a nightmare with the Hadoop's Eclipse plugin. First of all the latest Hadoop version (which is 1.1.1) doesn't even include the Eclipse plugin jar file. version 1.0.4 has the plugin, but it doesn't work. Earlier versions of Hadoop such as 0.22.0 have the plugin and it works, but then these versions of Hadoop are old, and I want to work wit the latest version. So, what is the deal with Eclipse plugin for Hadoop? Why latest versions either don't have the plugin, or if they do, then the plugin doesn't work? Does everyone has so much problem with this plugin? Should I give up on this plugin?
我对 Hadoop 的 Eclipse 插件有这样的噩梦。首先,最新的 Hadoop 版本(即 1.1.1)甚至不包含 Eclipse 插件 jar 文件。版本 1.0.4 有插件,但它不起作用。Hadoop 的早期版本(例如 0.22.0)具有插件并且可以正常工作,但是这些版本的 Hadoop 很旧,我想使用最新版本。那么,与 Hadoop 的 Eclipse 插件有什么关系?为什么最新版本没有插件,或者如果有,那么插件不起作用?大家对这个插件有这么大的问题吗?我应该放弃这个插件吗?
Thanks, Shannon
谢谢,香农
采纳答案by hs3180
I installed eclipse plugin for hadoop-1.0.4 yesterday with difficulty, and tested it successful.
我昨天为 hadoop-1.0.4 安装了 eclipse 插件,很困难,测试成功。
The reason for plugin not working is that the jar package lost some libs :
插件不工作的原因是 jar 包丢失了一些库:
- commons-cli-1.2.jar
- commons-configuration-1.6.jar
- Hymanson-core-asl-1.8.8.jar
- Hymanson-mapper-asl-1.8.8.jar
- commons-httpclient-3.0.1.jar
- commons-lang-2.4.jar
- commons-cli-1.2.jar
- commons-configuration-1.6.jar
- Hymanson-core-asl-1.8.8.jar
- Hymanson-mapper-asl-1.8.8.jar
- commons-httpclient-3.0.1.jar
- commons-lang-2.4.jar
you could cp this jars from ${hadoop}/libto ${jar}/lib, and don't forget modifying MANIFEST.
您可以将这个 jars 从${hadoop}/libcp到${jar}/lib,并且不要忘记修改MANIFEST。
For convenience, I add some code to ${eclipse-plugin-src}/build.xmltarget jar
为方便起见,我在${eclipse-plugin-src}/build.xml目标jar 中添加了一些代码
<copy file="${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-configuration-${commons-configuration.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-httpclient-${commons-httpclient.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-lang-${commons-lang.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/Hymanson-core-asl-${Hymanson.version}.jar" todir="${build.dir}/lib" verbose="true"/>
<copy file="${hadoop.root}/lib/Hymanson-mapper-asl-${Hymanson.version}.jar" todir="${build.dir}/lib" verbose="true"/>
and modified MANIFEST.MFin ${eclipse-plugin-src}/META-INF
并修改了${eclipse-plugin-src}/META-INF 中的MANIFEST.MF
undle-ClassPath: classes/,
lib/hadoop-core.jar,
lib/commons-cli-1.2.jar,
lib/commons-configuration-1.6.jar,
lib/Hymanson-core-asl-1.8.8.jar,
lib/commons-httpclient-3.0.1.jar,
lib/Hymanson-mapper-asl-1.8.8.jar,
lib/commons-lang-2.4.jar
rebuild eclipse-plugin, and HAVE FUN!
重建 eclipse-plugin,玩得开心!
回答by lcn
Well, combined with hs3180's answer, here is what I actually did in configuring the compiling.
好吧,结合hs3180的回答,这里是我在配置编译时实际做的。
In ${eclipse-plugin-src}/build.xml, use the following directives to include required jars by the eclipse-plugin. Note here that, instead of from
${hadoop.root}/build
, copying of thehadoop-core-${version}.jar
is now from${hadoop.root}
directly, because if you are using the compiled version of hadoop, the${hadoop.root}/build
folder would be actually empty. Copying of thecommons-cli-${commons-cli.version}.jar
is now from${hadoop.root}/lib
for the same reason.<!-- <copy file="${hadoop.root}/build/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/> --> <!-- <copy file="${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/> --> <copy file="${hadoop.root}/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/> <copy file="${hadoop.root}/lib/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-configuration-${commons-configuration.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-httpclient-${commons-httpclient.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-lang-${commons-lang.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/Hymanson-core-asl-${Hymanson.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/Hymanson-mapper-asl-${Hymanson.version}.jar" todir="${build.dir}/lib" verbose="true"/>
Modify the ${eclipse-plugin-src}/META-INF/MANIFEST.MFfile to accommodate the changes made to ${eclipse-plugin-src}/build.xml.
Bundle-ClassPath: classes/, lib/hadoop-core.jar, lib/commons-cli-1.2.jar, lib/commons-configuration-1.6.jar, lib/Hymanson-core-asl-1.8.8.jar, lib/commons-httpclient-3.0.1.jar, lib/Hymanson-mapper-asl-1.8.8.jar, lib/commons-lang-2.4.jar
Modify the ${hadoop.root}/src/contrib/build-contrib.xmlfile at two places. The first is to set up the properties needed for the plugin compiling. And the second is to make sure jars, especially
hadoop-core-1.0.4.jar
, in the${hadoop.root}
folder are visible to javac, because the eclipse-plugin references the hadoop classes. This setup is different from the first two in purpose and thus not dispensable.<!-- Properties added for compiling eclipse-plugin --> <!-- http://yiyujia.blogspot.com/2012/11/build-hadoop-eclipse-plugin-from-source.html --> <property name="eclipse.home" location="/Users/xuj/Downloads/eclipse/"/> <property name="version" value="1.0.4"/> <property name="commons-cli.version" value="1.2"/> <!-- the normal classpath --> <path id="contrib-classpath"> <fileset dir="${hadoop.root}"> <include name="*.jar" /> </fileset> <!-- more path elements go here --> </path>
在${eclipse-plugin-src}/build.xml 中,使用以下指令包含 eclipse-plugin 所需的 jars。在这里请注意,不是 from ,而是直接
${hadoop.root}/build
复制了hadoop-core-${version}.jar
now from${hadoop.root}
,因为如果您使用的是 hadoop 的编译版本,则该${hadoop.root}/build
文件夹实际上是空的。出于同样的原因,commons-cli-${commons-cli.version}.jar
现在复制了${hadoop.root}/lib
。<!-- <copy file="${hadoop.root}/build/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/> --> <!-- <copy file="${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/> --> <copy file="${hadoop.root}/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/> <copy file="${hadoop.root}/lib/commons-cli-${commons-cli.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-configuration-${commons-configuration.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-httpclient-${commons-httpclient.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/commons-lang-${commons-lang.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/Hymanson-core-asl-${Hymanson.version}.jar" todir="${build.dir}/lib" verbose="true"/> <copy file="${hadoop.root}/lib/Hymanson-mapper-asl-${Hymanson.version}.jar" todir="${build.dir}/lib" verbose="true"/>
修改${eclipse-plugin-src}/META-INF/MANIFEST.MF文件以适应对${eclipse-plugin-src}/build.xml 所做的更改。
Bundle-ClassPath: classes/, lib/hadoop-core.jar, lib/commons-cli-1.2.jar, lib/commons-configuration-1.6.jar, lib/Hymanson-core-asl-1.8.8.jar, lib/commons-httpclient-3.0.1.jar, lib/Hymanson-mapper-asl-1.8.8.jar, lib/commons-lang-2.4.jar
修改${hadoop.root}/src/contrib/build-contrib.xml文件两处。首先是设置插件编译所需的属性。第二是确保罐,特别是
hadoop-core-1.0.4.jar
,在该${hadoop.root}
文件夹是javac的可见的,因为Eclipse的插件引用的Hadoop类。这个设置在目的上不同于前两个,因此不是可有可无的。<!-- Properties added for compiling eclipse-plugin --> <!-- http://yiyujia.blogspot.com/2012/11/build-hadoop-eclipse-plugin-from-source.html --> <property name="eclipse.home" location="/Users/xuj/Downloads/eclipse/"/> <property name="version" value="1.0.4"/> <property name="commons-cli.version" value="1.2"/> <!-- the normal classpath --> <path id="contrib-classpath"> <fileset dir="${hadoop.root}"> <include name="*.jar" /> </fileset> <!-- more path elements go here --> </path>
When all files correctly configured, call 'ant jar' from ${eclipse-plugin-src}/
in the console shall be sufficient for the rest.
正确配置所有文件后,从控制台调用“ ant jar”${eclipse-plugin-src}/
就足够了。