记录一下自己常用的maven工程的pom.xml模板

1. 带有hadoop-CDH4.2.1的pom.xml模板

[html] view plain copy
 
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"  
  3.          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
  5.     <modelVersion>4.0.0</modelVersion>  
  6.   
  7.     <groupId>com.cxz</groupId>  
  8.     <artifactId>IntoRedis</artifactId>  
  9.     <version>1.0-SNAPSHOT</version>  
  10.   
  11.     <properties>  
  12.         <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>  
  13.         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
  14.     </properties>  
  15.   
  16.     <repositories>  
  17.         <repository>  
  18.             <id>cloudera</id>  
  19.             <name>cloudera maven repository</name>  
  20.             <url>https://repository.cloudera.com/content/repositories/releases</url>  
  21.         </repository>  
  22.     </repositories>  
  23.   
  24.     <dependencies>  
  25.         <dependency>  
  26.             <groupId>redis.clients</groupId>  
  27.             <artifactId>jedis</artifactId>  
  28.             <version>2.1.0</version>  
  29.             <type>jar</type>  
  30.         </dependency>  
  31.         <dependency>  
  32.             <groupId>commons-pool</groupId>  
  33.             <artifactId>commons-pool</artifactId>  
  34.             <version>1.6</version>  
  35.         </dependency>  
  36.         <dependency>  
  37.             <groupId>org.apache.hadoop</groupId>  
  38.             <artifactId>hadoop-examples</artifactId>  
  39.             <version>2.0.0-mr1-cdh4.2.1</version>  
  40.             <type>jar</type>  
  41.             <scope>provided</scope>  
  42.         </dependency>  
  43.         <dependency>  
  44.             <groupId>junit</groupId>  
  45.             <artifactId>junit</artifactId>  
  46.             <version>4.8.2</version>  
  47.             <scope>test</scope>  
  48.         </dependency>  
  49.         <dependency>  
  50.             <groupId>org.apache.mrunit</groupId>  
  51.             <artifactId>mrunit</artifactId>  
  52.             <version>1.0.0</version>  
  53.             <classifier>hadoop1</classifier>  
  54.             <scope>test</scope>  
  55.         </dependency>  
  56.         <dependency>  
  57.             <groupId>org.apache.hadoop</groupId>  
  58.             <artifactId>hadoop-common</artifactId>  
  59.             <version>2.0.0-cdh4.2.1</version>  
  60.             <type>jar</type>  
  61.             <exclusions>  
  62.                 <exclusion>  
  63.                     <artifactId>kfs</artifactId>  
  64.                     <groupId>net.sf.kosmosfs</groupId>  
  65.                 </exclusion>  
  66.             </exclusions>  
  67.             <scope>provided</scope>  
  68.         </dependency>  
  69.     </dependencies>  
  70.   
  71.     <build>  
  72.         <plugins>  
  73.             <plugin>  
  74.                 <groupId>org.apache.maven.plugins</groupId>  
  75.                 <artifactId>maven-compiler-plugin</artifactId>  
  76.                 <version>2.3.2</version>  
  77.                 <configuration>  
  78.                     <source>1.7</source>  
  79.                     <target>1.7</target>  
  80.                 </configuration>  
  81.             </plugin>  
  82.             <plugin>  
  83.                 <groupId>org.apache.maven.plugins</groupId>  
  84.                 <artifactId>maven-assembly-plugin</artifactId>  
  85.                 <version>2.4</version>  
  86.                 <configuration>  
  87.                     <descriptors>  
  88.                         <descriptor>assembly.xml</descriptor>  
  89.                     </descriptors>  
  90.                     <archive>  
  91.                         <manifest>  
  92.                             <mainClass>com.cxz.redis.IntoRedis</mainClass>  
  93.                         </manifest>  
  94.                     </archive>  
  95.                 </configuration>  
  96.                 <executions>  
  97.                     <execution>  
  98.                         <id>make-assembly</id>  
  99.                         <phase>package</phase>  
  100.                         <goals>  
  101.                             <goal>single</goal>  
  102.                         </goals>  
  103.                     </execution>  
  104.                 </executions>  
  105.             </plugin>  
  106.         </plugins>  
  107.     </build>  


2. assembly.xml文件

[html] view plain copy
 
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <assembly  
  3.     xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'  
  4.     xmlns='http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0'  
  5.     xsi:schemaLocation='http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd'>  
  6.     <id>job</id>  
  7.     <formats>  
  8.         <format>jar</format>  
  9.     </formats>  
  10.     <includeBaseDirectory>false</includeBaseDirectory>  
  11.     <dependencySets>  
  12.         <dependencySet>  
  13.             <unpack>false</unpack>  
  14.             <scope>runtime</scope>  
  15.             <outputDirectory>lib</outputDirectory>  
  16.             <excludes>  
  17.                 <exclude>${groupId}:${artifactId}</exclude>  
  18.             </excludes>  
  19.         </dependencySet>  
  20.         <dependencySet>  
  21.             <unpack>true</unpack>  
  22.             <includes>  
  23.                 <include>${groupId}:${artifactId}</include>  
  24.             </includes>  
  25.         </dependencySet>  
  26.     </dependencySets>  
  27. </assembly>  


3. maven的基本使用命令

mvn compile

mvn test

mvn test-compile

mvn package

mvn clean

原文地址:https://www.cnblogs.com/ruiati/p/6508587.html