hadoop mapReduce 项目下 pom.xml 的设置

Setting for pom.xml under hadoop mapReduce project

我创建了一个字数统计项目,并通过 maxmind(maven) 使用 maven 导入了 GeoIP - 这个 Geoip 项目是 build with maven

导入后,我在字数统计项目旁边有一个新项目 (geoIP),其中包含由 eclipse 创建的 pom.xml(很长)。

但在上面 link 他们说添加到 pom.xml

<dependency>
    <groupId>com.maxmind.geoip2</groupId>
    <artifactId>geoip2</artifactId>
    <version>v2.3.0</version>
</dependency>

  1. 如果 eclipse 为我创建了 pom.xml,我不明白我应该用上面的代码删除还是添加它?

  2. 我需要多少 pom.xml 个文件?

  3. MapReduce项目是否也需要用maven构建?

我没有使用过 GeoIP2,但这应该不会有什么不同。

if eclipse created pom.xml for me should I delete OR add it with the above code ?

Eclipse 默认为您的 geoip 项目创建了一个 pom.xml 文件。您应该为文件添加新的依赖项才能访问 GeoIP。

How many pom.xml files do I need ?

真的取决于你的整体项目结构。您可能应该看看这个 SO question and take a peek at this example of multiple maven files for a project 的答案。

Does MapReduce project needs to be built with maven as well ?

不,但我会推荐它,它会让您的生活更轻松。这是我对 Map-Reduce 作业的依赖项:

<dependencies>
    <!-- junit testing framework -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <!-- hadoop hdfs components -->
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-hdfs</artifactId>
        <version>2.7.1</version>
    </dependency>
    <!-- hadoop map-reduce components -->
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-mapreduce-client-core</artifactId>
        <version>2.7.1</version>
    </dependency>
    <!-- hadoop common components -->
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>2.7.1</version>
    </dependency>
</dependencies> 

所有附加依赖项位于 Maven Repository for Hadoop