读书人

Nutch 施用入门(三)配置文件的加

发布时间: 2012-07-25 09:43:05 作者: rapoo

Nutch 使用入门(三)——配置文件的加载

/** Add the standard Nutch resources to {@link Configuration}. */  public static Configuration addNutchResources(Configuration conf) {    conf.addResource("nutch-default.xml");    conf.addResource("nutch-site.xml");    return conf;  }

?

我们看到,先加载了nutch-default.xml文件,后加载了nutch-site.xml文件。所以nutch-site.xml中的配置会覆盖nutch-default.xml中的配置。下面我们回到crawl类的main方法,继续往下看。调用了conf.addResource("crawl-tool.xml");这表明crawl-tool.xml配置文件是最后加载。

?

通过上面简单的源码分析,我们不难看出Nutch配置文件的优先级。

Nutch自己的配置文件:crawl-tool.xml? >? nutch-site.xml? >? nutch-default.xml

hadoop的配置文件:hadoop-site.xml?? >? hadoop-default.xml

?

当然,因为nutch的配置文件后于Hadoop的配置文件的加载,nutch的配置也会覆盖Hadoop配置文件中的配置。需要明白的是覆盖的不是整个配置文件,而是单独的Property。

读书人网 >互联网

热点推荐