参考了不少nutch插件开发的文章都不完整,经过多次调试研究才成功,下面将注意要点列出希望能对nutch应用开发爱好者提供帮助。
nutch开发环境搭建请参考
一、插件程序结构以nutch中的parse-html解析html的插件为例介绍。
parse-html跟目录中包含3个xml分别是build.xml、 ivy.xml、 plugin.xml,一个源程序目录src。
实现了接口的类为java.org.apache.nutch.parse.html.HtmlParser.java ,所有的可实现接口都包含在src\plugin\nutch-extensionpoints\plugin.xml中
接口示例如下所示:
- public
class HtmlParser implements Parser { -
..... -
public ParseResult getParse(Content content) { -
..... -
} -
..... - }
从代码中可以看到实现了Parser接口, getParse()为接口中定义的方法。
1、src/plugin/build.xml在<target name="deploy">;<target name="test">;<target name="clean">分别增加相应配置。
运行ant编译,nutch/build中编译生成相应的文件夹即成功。
三、将插件配置到