1. surefire插件

Maven Surefire 插件有一个 test 目标,该目标被绑定在了 test 阶段。 
test 目标执行项目中所有能在 src/test/java 找到的并且文件名与 **/Test*.java, **/*Test.java 匹配的所有单元测试 ,
在 Maven Surefire 插件执行 JUnit 测试的时候,它同时也在 /target/surefire-reports 
目录下生成 XML 和常规文本报告。 
如果你的测试失败了,你可以去查看这个目录,里面有你单元测试生成的异常堆栈信息和错误信息。
当Maven 遇到一个测试失败,它默认的行为是停止当前的构建。 如果你希望继续构建项目,即使 Surefire 插件
遇到了失败的单元测试,你就需要设置 Surefire 的testFailureIgnore 这个配置属性为 true。
 
  1. <project>
  2. [...]
  3. <build>
  4. <plugins>
  5. <plugin>
  6. <groupId>org.apache.maven.plugins</groupId>
  7. <artifactId>maven-surefire-plugin</artifactId>
  8. <configuration>
  9. <testFailureIgnore>true</testFailureIgnore>
  10. </configuration>
  11. </plugin>
  12. </plugins>
  13. </build>
  14. [...]
  15. </project>

这个表达式可以从命令行通过 -D 参数设置。mvn test -Dmaven.test.failure.ignore=true

Maven 提供了跳过单元测试的能力,只需要使用 Surefire 插件的 skip 参数。 在命令行,只要简单的给任何目标添加
maven.test.skip 属性就能跳过测试:mvn install -Dmaven.test.skip=true
另一种配置 Maven 跳过单元测试的方法是给你项目的 pom.xml 添加这个配置
  1. <project>
  2. [...]
  3. <build>
  4. <plugins>
  5. <plugin>
  6. <groupId>org.apache.maven.plugins</groupId>
  7. <artifactId>maven-surefire-plugin</artifactId>
  8. <configuration>
  9. <skip>true</skip>
  10. </configuration>
  11. </plugin>
  12. </plugins>
  13. </build>
  14. [...]
  15. </project>

2. assembly插件

Maven Assembly 插件是一个用来创建你应用程序特有分发包的插件。 你可以使用 Maven Assembly 插件

以你希望的任何形式来装配输出,只需定义一个自定义的装配描述符,即可生成一个可分发的JAR文件,该文件包含

了项目的二进制文件和所有的依赖。

要配置 Maven Assembly 插件, 需要在 pom.xml 中的build 配置中添加如下的 plugin 配置。如下图所示

  1. <project>
  2. [...]
  3. <build>
  4. <plugins>
  5. <plugin>
  6. <artifactId>maven-assembly-plugin</artifactId>
  7. <configuration>
  8. <descriptorRefs>
  9. <descriptorRef>jar-with-dependencies</descriptorRef>
  10. </descriptorRefs>
  11. </configuration>
  12. </plugin>
  13. </plugins>
  14. </build>
  15. [...]
  16. </project>

添加好这些配置以后,你可以通过运行 mvn assembly:assembly来构建这个装配。将工程依赖的jar包和工程都打成一个jar打包

在 target/***-1.0-jar-with-dependencies.jar 装配好之后, 我们可以在命令行重新运行 Main 类

Java -cp **-1.0-jar-with-dependencies.jar *.*.Main

3. compiler插件

用于编译源代码,默认在compile阶段被调用。两个goal,compiler:compile/compiler:testCompile

windows平台默认使用GBK编码,如果工程编码为utf8,也需要在compiler插件中指出,否则按GBK编码,也会出问题

  1. <plugin>
  2. <groupId>org.apache.maven.plugins</groupId>
  3. <artifactId>maven-compiler-plugin</artifactId>
  4. <version>3.3</version>
  5. <configuration>
  6. <!--源码的Java版本-->
  7. <source>1.7</source>
  8. <!--运行环境的Java版本-->
  9. <target>1.7</target>
  10. <encoding>UTF8</encoding>
  11. </configuration>
  12. <executions>
        <execution>
        <id>log4j-plugin-processor</id>
        <goals>
        <goal>compile</goal>
        </goals>
              <phase>process-classes</phase>
              <configuration>
                   <proc>only</proc>
                   <annotationProcessors>
                        <annotationProcessor>org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor</annotationProcessor>
                  </annotationProcessors>
              </configuration>
        </execution>
    </executions>

  13. </plugin>

4、Resource插件

  1. <filters>
  2. <filter>${user.home}/asssd.properties</filter>
  3. </filters>
  4. <resources>
  5. <resource>
  6. <directory>src/main/resources</directory>
  7. <filtering>true</filtering>
  8. <includes>
  9. <include>**/*</include>
  10. </includes>
  11. </resource>
  12. <resource>
  13. <directory>src/main/java</directory>
  14. <includes>
  15. <include>**.xml</include>
  16. </includes>
  17. </resource>
  18. </resources>

运行打包命令时,将src/main/resources中的所有文件和src/main/java目录下的所有.xml文件打到jar包中。
其中filters过滤器的作用是将所有引用文件中的${变量名称},替换成antx.properties文件中的变量值。要使用过滤器时,首先需要设置过滤器:
<filters>    
       <filter>${user.home}/antx.properties</filter>
</filters>
然后再启动过滤器, true需要过滤,false不需要过滤:
<filtering>true</filtering>

maven pom.xml几个特殊的插件的更多相关文章

  1. 史上最全的maven pom.xml文件教程详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  2. 在maven pom.xml中加载不同的properties ,如localhost 和 dev master等jdbc.properties 中的链接不一样

    [参考]:maven pom.xml加载不同properties配置[转] 首先 看看效果: 点开我们项目中的Maven projects 后,会发现右侧 我们profile有个可勾选选项.默认勾选l ...

  3. Maven pom.xml文件详解

    Maven pom.xml文件详解 一.简介 POM全称是Project Object Model,即项目对象模型. pom.xml是maven的项目描述文件,它类似与antx的project.xml ...

  4. (转)Maven pom.xml 配置详解

    背景:maven一直感觉既熟悉又陌生,归根结底还是自己不太熟. 1 什么是pom? pom作为项目对象模型.通过xml表示maven项目,使用pom.xml来实现.主要描述了项目:包括配置文件:开发者 ...

  5. Maven(四-2) Maven pom.xml 配置详解

    转载于:http://niuzhenxin.iteye.com/blog/2042102 什么是pom?    pom作为项目对象模型.通过xml表示maven项目,使用pom.xml来实现.主要描述 ...

  6. Maven pom.xml 全配置(二)不常用配置

    Maven pom.xml 全配置(二)不常用配置 这里贴出Maven pom.xml文件中使用率较少的配置参数,如果此篇文档中没有找到你想要的参数,移步Maven pom.xml 全配置(一)常用配 ...

  7. Maven pom.xml 全配置(一)常用配置

    Maven pom.xml 全配置(一)常用配置 这里贴出一个Maven中出现频率较高的配置参数注释,方便理解项目中Maven的配置具体的作用.如果在此博文中没有找到你想看到的参数,可以移步Maven ...

  8. Maven - pom.xml 文件

    章节 Maven – 简介 Maven – 工作原理 Maven – Repository(存储库) Maven – pom.xml 文件 Maven – 依赖管理 Maven – 构建生命周期.阶段 ...

  9. myeclipse maven pom.xml 配置错误

    http://www.oschina.net/question/2265006_219341#tags_nav maven pom.xml 配置文件错误       腾讯云消息队列CMQ架构解析> ...

随机推荐

  1. 建立dblink(database link)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/bisal/article/details/26730993 database linke是建立一个数 ...

  2. hadoop之 hadoop日志存放路径

    环境:[root@hadp-master hadoop-2.7.4]# hadoop versionHadoop 2.7.4 Hadoop的日志大致可以分为两类: (1).Hadoop系统服务输出的日 ...

  3. 基于PhantomJS的网页抓取及写入文件

    # coding=utf-8 from selenium import webdriver from selenium.webdriver.common.desired_capabilities im ...

  4. Bootstrap-Other:CSS编码规范

    ylbtech-Bootstrap-Other:CSS编码规范 1.返回顶部 1. Bootstrap CSS编码规范 语法 用两个空格来代替制表符(tab) -- 这是唯一能保证在所有环境下获得一致 ...

  5. 学习笔记之C++ Primer中文版(第五版)

    非常权威系统的语言书,正好学习下C++11内容. C++ Primer_百度百科 http://baike.baidu.com/link?url=YLvDJE9w3CjGp3eQwjuXYKUZs7v ...

  6. git grade 版本下载及安装

    Git 2.11.1x64下载 gradle各版本下载地址 1. Git安装与配置 Gradle 用法总结

  7. Asp.net 页面传值的方法

    ASP.NET页面传值的方法 From:Refresh-air 在面试的时候,经常会遇到这样的问题,其实我们会对其中的几种方法比较熟悉,因为项目中经常使用.但是要全面的回答ASP.NET中页面传值的方 ...

  8. Oracle数据库物理结构

    Oracle数据库物理结构 oracle的数据,实际上是以文件的形式来保存的,文件中出了保存用户的数据之外,还需要保存管理数据和日志数据等等.作为一个DBA,必须需要知道自己的数据分别保存在什么位置上 ...

  9. JS执行删除前的判断

    JS执行删除前如何实现判断. 一. <script> function del(){ if(confirm("确认删除吗")){ alert("yes&quo ...

  10. leetcode861

    public class Solution { public int MatrixScore(int[][] A) { ); ].GetLength(); //判断最高位是否为1 ; i < r ...