CALL NOW 713-568-9753
11 Dec 2013
maven project pom.xml for Hadoop/HBase dependencies
ElephantScale AdminPosted in: Dev Stuff 0

If you are building a Java project that has Hadoop or HBase dependency  (for example a Java mapreduce application), here is a simple POM.xml to get you started

1) project structure:

pom.xml
src/main/java   <--- all the java code goes here

2) POM.XML
here is the pom.xml on github : https://gist.github.com/sujee/7916669

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>mygroup</groupId> <!-- change this -->
    <artifactId>project_name</artifactId> <!-- change this -->
    <packaging>jar</packaging>
    <version>1.0</version>
    <name>Sample Project Name</name> <!-- change this -->

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <version>1.2.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.jackson</groupId>
                    <artifactId>jackson-core-asl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-test</artifactId>
            <version>1.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase</artifactId>
            <version>0.90.2</version>
        </dependency>
    </dependencies>
</project>

3) Compiling
To compile
$ mvn compile
to create jar
$ mvn package
This will create a jar file in target/ directory

4) Adding more dependencies
You can search and add dependencies from http://mvnrepository.com/

Leave a Reply

Your email address will not be published. Required fields are marked *