1. 带有hadoop-CDH4.2.1的pom.xml模板
- <?xml version="1.0" encoding="UTF-8"?>
- <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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.cxz</groupId>
- <artifactId>IntoRedis</artifactId>
- <version>1.0-SNAPSHOT</version>
- <properties>
- <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <repositories>
- <repository>
- <id>cloudera</id>
- <name>cloudera maven repository</name>
- <url>https://repository.cloudera.com/content/repositories/releases</url>
- </repository>
- </repositories>
- <dependencies>
- <dependency>
- <groupId>redis.clients</groupId>
- <artifactId>jedis</artifactId>
- <version>2.1.0</version>
- <type>jar</type>
- </dependency>
- <dependency>
- <groupId>commons-pool</groupId>
- <artifactId>commons-pool</artifactId>
- <version>1.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-examples</artifactId>
- <version>2.0.0-mr1-cdh4.2.1</version>
- <type>jar</type>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.mrunit</groupId>
- <artifactId>mrunit</artifactId>
- <version>1.0.0</version>
- <classifier>hadoop1</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- <version>2.0.0-cdh4.2.1</version>
- <type>jar</type>
- <exclusions>
- <exclusion>
- <artifactId>kfs</artifactId>
- <groupId>net.sf.kosmosfs</groupId>
- </exclusion>
- </exclusions>
- <scope>provided</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <descriptors>
- <descriptor>assembly.xml</descriptor>
- </descriptors>
- <archive>
- <manifest>
- <mainClass>com.cxz.redis.IntoRedis</mainClass>
- </manifest>
- </archive>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
2. assembly.xml文件
- <?xml version="1.0" encoding="UTF-8"?>
- <assembly
- xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
- xmlns='http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0'
- xsi:schemaLocation='http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd'>
- <id>job</id>
- <formats>
- <format>jar</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
- <dependencySets>
- <dependencySet>
- <unpack>false</unpack>
- <scope>runtime</scope>
- <outputDirectory>lib</outputDirectory>
- <excludes>
- <exclude>${groupId}:${artifactId}</exclude>
- </excludes>
- </dependencySet>
- <dependencySet>
- <unpack>true</unpack>
- <includes>
- <include>${groupId}:${artifactId}</include>
- </includes>
- </dependencySet>
- </dependencySets>
- </assembly>
3. maven的基本使用命令
mvn compile
mvn test
mvn test-compile
mvn package
mvn clean