首先到nutch官网上找到FAQ连接http://wiki.apache.org/nutch/FAQ,进入连接html
点击第二个连接查看。java
参照文档进行配置,有卡壳不明白的地方,继续在网上针对具体问题查找资料。集成时可参照http://blog.csdn.net/witsmakemen/article/details/8866235。apache
A、在windows上安装配置Apache Ant,http://ant.apache.org/manual/index.htmlwindows
B、安装Eclipse,这个不用说确定是必须的。eclipse
C、在Linux安装svn。目的:迁出nutch1.7源代码。svn
D、在Linux下检出nutch1.7代码oop
[root@nutch-five branch-1.7]# svn co http://svn.apache.org/repos/asf/nutch/branches/branch-1.7/测试
E、在Linux安装ivy插件。目的,根据ivy配置文件动态下载jar包。fetch
F、编译branch1.7ui
[root@nutch-five branch-1.7]# ant
找到 conf 文件夹 ,而后点击 Add Folder 'conf' to build path
defautl output 设置为 apache-nutch-1.7/conf
在这儿我由于不能建立conf,因此写为conf1
点击Finish
至此,创建成功。
以parse-html为例:
import org.cyberneko.html.parsers.*;
这里报错是由于缺乏 nekohtml-0.9.5.jar
找到runtime/local/plugins/lib-nekohtml/nekohtml-jar,单击右键add to build path,其余bug以此类推。
在这儿一共要加runtime/local/plugins/lib-nekohtml/nekohtml-jar、runtime/local/plugins/parse-html/tagsoup.jar、runtime/local/plugins/feed/rome.jar(解决了com.sun.syndication.io.SyndFeedInput报错问题)、runtime/local/plugins/urlfilter-automaton/automaton.jar(解决dk.brics.automaton.RunAutomaton报错问题)
至此整个工程将应该不会有错了。
在文件夹内新建文件url,存放待抓取网址
解决方案:
下载hadoop的源代码,从新编译hadoop的hadoop-core.jar包,替换掉nutch项目中的hadoop的jar包。(注意:下载时先肯定nutch引用的hadoop的哪一个版本的jar包,而后下载对应版本。在runtime/local/lib中能够找对hadoop的jar包。)
下载hadoop源代码:
下载连接:http://apache.dataguru.cn/hadoop/common/hadoop-1.2.1/
1、注释掉build.xml中的
<target name="create-native-configure">
<exec executable="autoreconf" dir="${native.src.dir}" searchpath="yes" failonerror="yes"> <arg value="-if"/>
</exec>
</target>
2、去掉compile-core-native中的create-native-configure依赖
<target name="compile-core-native" depends="create-native-configure,compile-core-classes"
if="compile.native">
3、修改hadoop-1.1.2/src/core/org/apache/hadoop/fs/FileUtil.java 691行,把throw new IOException改成LOG.warn
4、用ant编译项目,编译成功后从build文件夹中取出hadoop-core.jar文件夹,放入nutch项目中,替换项目中原有hadoop-core.jar,放入build/lib文件夹下。再经过buildpath添加jar包。
添加完毕后,运行测试
解决方案:
将nutch-default.xml中的
<property>
<name>plugin.folders</name>
<value>./src/plugin</value>
<description>Directories where nutch plugins are located. Each
element may be a relative or absolute path. If absolute, it is used
as is. If relative, it is searched for on the classpath.</description>
</property>
红色处改一下就能够了。
参照上边的运行方法,继续运行测试,产生异常:
解决方案:
连接不成功,能够忽略,对程序没有影响。
至此,nutch在eclipse中集成成功。
解决方案:
从新编译hadoop的hadoop-core.jar包,替换掉nutch项目中的hadoop的jar包
1、注释掉build.xml中的
<target name="create-native-configure">
<exec executable="autoreconf" dir="${native.src.dir}" searchpath="yes" failonerror="yes"> <arg value="-if"/>
</exec>
</target>
2、去掉compile-core-native中的create-native-configure依赖
<target name="compile-core-native" depends="create-native-configure,compile-core-classes"
if="compile.native">
3、修改hadoop-1.1.2/src/core/org/apache/hadoop/fs/FileUtil.java 691行,把throw new IOException改成LOG.warn
4、用ant编译项目,编译成功后从build文件夹中取出hadoop-core.jar文件夹,放入nutch项目中,替换项目中原有hadoop-core.jar,放入build/lib文件夹下。再经过buildpath添加jar包。
添加完毕后,运行测试
sun.net包里的类,在eclipse里默认是不让用的。解决办法是自定义access rules工程上右键->工程属性->java builder path->Libraries标签,点击JRE System Library里面的Access rules,add sun/** 为accessible,若是该项存在,就edit。
具体操做方法:
问题解决后,发现继续有错,缺乏ant的jar包,添加ant的jar包。