zoukankan      html  css  js  c++  java
  • (三)Maven基本概念——常用插件的配置

    看注释————

    pom.xml

      1 <project xmlns="http://maven.apache.org/POM/4.0.0" 
      2      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      3      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4   
      5   <modelVersion>4.0.0</modelVersion>
      6   
      7   <!-- 坐标、版本以及打包方式 -->
      8   <groupId>com.alanlee</groupId>
      9   <artifactId>UidpWeb</artifactId>
     10   <version>0.0.1-SNAPSHOT</version>
     11   <packaging>war</packaging>
     12   
     13   <!-- maven属性的使用 -->
     14   <properties>
     15       <plugin.version>2.5</plugin.version>
     16   </properties>
     17   
     18   <!-- 依赖配置的使用 -->
     19   <dependencies>
     20       
     21     <dependency>
     22         <groupId>junit</groupId>
     23         <artifactId>junit</artifactId>
     24         <version>4.11</version>
     25         <!-- 测试范围有效,在编译和打包时都不会使用这个依赖 -->
     26         <scope>test</scope>
     27     </dependency>
     28     
     29     <dependency>
     30         <groupId>javax.servlet</groupId>
     31         <artifactId>servlet-api</artifactId>
     32         <version>2.5</version>
     33         <!-- 在编译和测试的过程有效,最后生成war包时不会加入 -->
     34         <scope>provided</scope>
     35     </dependency>
     36     
     37     <dependency>
     38         <groupId>javax.servlet.jsp</groupId>
     39         <artifactId>jsp-api</artifactId>
     40         <version>2.2</version>
     41         <!-- 在编译和测试的过程有效,最后生成war包时不会加入 -->
     42         <scope>provided</scope>
     43     </dependency>
     44     
     45   </dependencies>
     46   
     47   <!-- 用来支持项目发布到私服中,用来配合deploy插件的使用 -->
     48   <distributionManagement>
     49       <!-- 发布版本 -->
     50     <repository>
     51         <id>releases</id>
     52         <name>public</name>
     53         <url>http://10.200.11.21:8081/nexus/content/repositories/releases/</url>
     54     </repository>
     55     <!-- 快照版本 -->
     56     <snapshotRepository>
     57         <id>snapshots</id>
     58         <name>Snapshots</name>
     59         <url>http://10.200.11.21:8081/nexus/content/repositories/snapshots</url>
     60     </snapshotRepository>
     61   </distributionManagement>
     62   
     63   <!-- 注意体会插件配置的顺序,这正体现了一个maven的运行流程 -->
     64   <build>
     65       <plugins>
     66           <!-- 插件使用练习 -->
     67           <!-- 清理插件的使用,maven3.0.4会默认使用2.4.1版本的clean插件 -->
     68         <plugin>
     69             <groupId>org.apache.maven.plugins</groupId>
     70             <artifactId>maven-clean-plugin</artifactId>
     71             <version>${plugin.version}</version>
     72             <executions>
     73                 <execution>
     74                     <id>auto-clean</id>
     75                     <!-- clean生命周期clean阶段 -->
     76                     <phase>clean</phase>
     77                     <goals>
     78                         <!-- 执行clean插件的clean目标 -->
     79                         <goal>clean</goal>
     80                     </goals>
     81                 </execution>
     82             </executions>
     83         </plugin>
     84         
     85         <!-- maven-resources-plugin在maven3.0.4中默认使用2.5版本的resources -->
     86         
     87         <!-- 编译插件的使用,maven3.0.4会默认使用2.3.2版本的compile插件 -->
     88         <plugin>
     89             <groupId>org.apache.maven.plugins</groupId>
     90             <artifactId>maven-compiler-plugin</artifactId>
     91             <version>${plugin.version}</version>
     92             <configuration>
     93                 <!-- 源代码使用的jdk版本 -->
     94                 <source>1.7</source>
     95                 <!-- 构建后生成class文件jdk版本 -->
     96                 <target>1.7</target>
     97             </configuration>
     98         </plugin>
     99         
    100         <!-- maven-surefire-plugin插件,maven3.0.4默认使用2.10版本的surefire插件 -->
    101         <plugin>
    102             <groupId>org.apache.maven.plugins</groupId>
    103             <artifactId>maven-surefire-plugin</artifactId>
    104             <version>${plugin.version}</version>
    105             <configuration>
    106                 <!-- 改变测试报告生成目录 ,默认为target/surefire-reports-->
    107                 <!-- project.build.directory表示maven的属性,这里指的是构建的目录下面test-reports,project.build.directory就是pom标签的值 -->
    108                 <reportsDirectory>${project.build.directory}/test-reports</reportsDirectory>
    109             </configuration>
    110         </plugin>
    111         
    112         <!-- war包插件的使用,maven3.0.4会默认使用xxx版本的war插件,建议配置编码格式和打包名称 -->
    113         <plugin>
    114             <groupId>org.apache.maven.plugins</groupId>
    115             <artifactId>maven-war-plugin</artifactId>
    116             <!-- 利用属性传递版本号 -->
    117             <version>${plugin.version}</version>
    118             <configuration>
    119                 <!-- 设置编码 -->
    120                 <encoding>UTF-8</encoding>
    121                 <!-- 设置名称 -->
    122                 <warName>ROOT</warName>
    123             </configuration>
    124         </plugin>
    125         
    126         <!-- maven-install-plugin插件一般不需要配置,maven3.0.4默认使用2.3.1版本的install插件 -->
    127         
    128         <!-- 部署插件的使用,maven3.0.4会默认使用2.7版本的deploy插件 -->
    129         <plugin>
    130             <groupId>org.apache.maven.plugins</groupId>
    131             <artifactId>maven-deploy-plugin</artifactId>
    132             <version>${plugin.version}</version>
    133             <configuration>
    134                 <!-- 更新元数据 -->
    135                 <updateReleaseInfo>true</updateReleaseInfo>
    136             </configuration>
    137         </plugin>
    138         
    139     </plugins>
    140   </build>
    141   
    142 </project>

    from: http://www.cnblogs.com/AlanLee/p/6428859.html

  • 相关阅读:
    Constants and Variables
    随想
    C#基础篇之语言和框架介绍
    Python基础19 实例方法 类方法 静态方法 私有变量 私有方法 属性
    Python基础18 实例变量 类变量 构造方法
    Python基础17 嵌套函数 函数类型和Lambda表达式 三大基础函数 filter() map() reduce()
    Python基础16 函数返回值 作用区域 生成器
    Python基础11 List插入,删除,替换和其他常用方法 insert() remove() pop() reverse() copy() clear() index() count()
    Python基础15 函数的定义 使用关键字参数调用 参数默认值 可变参数
    Python基础14 字典的创建修改访问和遍历 popitem() keys() values() items()
  • 原文地址:https://www.cnblogs.com/zjfjava/p/6819181.html
Copyright © 2011-2022 走看看