maven pom.xml几个特殊的插件
1. surefire插件
- <project>
- [...]
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <testFailureIgnore>true</testFailureIgnore>
- </configuration>
- </plugin>
- </plugins>
- </build>
- [...]
- </project>
这个表达式可以从命令行通过 -D 参数设置。mvn test -Dmaven.test.failure.ignore=true
maven.test.skip 属性就能跳过测试:mvn install -Dmaven.test.skip=true
- <project>
- [...]
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
- [...]
- </project>
2. assembly插件
Maven Assembly 插件是一个用来创建你应用程序特有分发包的插件。 你可以使用 Maven Assembly 插件
以你希望的任何形式来装配输出,只需定义一个自定义的装配描述符,即可生成一个可分发的JAR文件,该文件包含
了项目的二进制文件和所有的依赖。
要配置 Maven Assembly 插件, 需要在 pom.xml 中的build 配置中添加如下的 plugin 配置。如下图所示
- <project>
- [...]
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- </configuration>
- </plugin>
- </plugins>
- </build>
- [...]
- </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插件
windows平台默认使用GBK编码,如果工程编码为utf8,也需要在compiler插件中指出,否则按GBK编码,也会出问题
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.3</version>
- <configuration>
- <!--源码的Java版本-->
- <source>1.7</source>
- <!--运行环境的Java版本-->
- <target>1.7</target>
- <encoding>UTF8</encoding>
- </configuration>
<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>- </plugin>
4、Resource插件
- <filters>
- <filter>${user.home}/asssd.properties</filter>
- </filters>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**.xml</include>
- </includes>
- </resource>
- </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几个特殊的插件的更多相关文章
- 史上最全的maven pom.xml文件教程详解
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- 在maven pom.xml中加载不同的properties ,如localhost 和 dev master等jdbc.properties 中的链接不一样
[参考]:maven pom.xml加载不同properties配置[转] 首先 看看效果: 点开我们项目中的Maven projects 后,会发现右侧 我们profile有个可勾选选项.默认勾选l ...
- Maven pom.xml文件详解
Maven pom.xml文件详解 一.简介 POM全称是Project Object Model,即项目对象模型. pom.xml是maven的项目描述文件,它类似与antx的project.xml ...
- (转)Maven pom.xml 配置详解
背景:maven一直感觉既熟悉又陌生,归根结底还是自己不太熟. 1 什么是pom? pom作为项目对象模型.通过xml表示maven项目,使用pom.xml来实现.主要描述了项目:包括配置文件:开发者 ...
- Maven(四-2) Maven pom.xml 配置详解
转载于:http://niuzhenxin.iteye.com/blog/2042102 什么是pom? pom作为项目对象模型.通过xml表示maven项目,使用pom.xml来实现.主要描述 ...
- Maven pom.xml 全配置(二)不常用配置
Maven pom.xml 全配置(二)不常用配置 这里贴出Maven pom.xml文件中使用率较少的配置参数,如果此篇文档中没有找到你想要的参数,移步Maven pom.xml 全配置(一)常用配 ...
- Maven pom.xml 全配置(一)常用配置
Maven pom.xml 全配置(一)常用配置 这里贴出一个Maven中出现频率较高的配置参数注释,方便理解项目中Maven的配置具体的作用.如果在此博文中没有找到你想看到的参数,可以移步Maven ...
- Maven - pom.xml 文件
章节 Maven – 简介 Maven – 工作原理 Maven – Repository(存储库) Maven – pom.xml 文件 Maven – 依赖管理 Maven – 构建生命周期.阶段 ...
- myeclipse maven pom.xml 配置错误
http://www.oschina.net/question/2265006_219341#tags_nav maven pom.xml 配置文件错误 腾讯云消息队列CMQ架构解析> ...
随机推荐
- python自动解析301、302重定向链接
使用模块requests 方式代码如下: import requests url_string="http://******" r = requests.head(url_stri ...
- php switch case的"bug"
首先说明,这不是一个bug.应该说是一个比较容易中招的陷阱. 今天使用switch遇到一个问题,代码如下: <?php $num = 0; switch ($price) { case $pri ...
- apache-tomcat-7.0.8\bin\tcnative-1.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform
问题: apache-tomcat-7.0.8\bin\tcnative-1.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform 解决:jd ...
- android 点击返回键 以及 加载activity 生命周期 记录。。。,一目了然
简叙 Activity 生命周期及android 返回按钮捕捉 @Override protected void onPostCreate(Bundle savedInstanceState) { ...
- 峰Spring4学习(6)spring AOP的应用例子
一.AOP简介: 二.AOP实例: 三.使用的例子 需求:在student添加的前后,打印日志信息: 0)spring AOP需要引用的jar包: 1)StudentService.java接口: p ...
- Java 字符串拼接 StringBuilder() StringBuffer
字符串拼接 普通方式 public class StringDemo2 { public static void main(String[] args) { // 表示获取从1970- ...
- [转][C#]常用开源项目
本文来自:http://www.cnblogs.com/sunxuchu/p/6047589.html 新增两个: 纸壳CMS http://www.zkea.net/zkeacms https:// ...
- Ngnix常用的操作
Nginx的常用参数如下: # /usr/local/nginx/sbin/nginx -h nginx version: nginx/0.7.63 Usage: nginx [-?hvVt] [-s ...
- C#中的参数关键字params
class 参数 { public void doSome(string str,params int[] values){ ) { ; i < values.Length; i++) { Co ...
- Docker系列06:Linux修改docker镜像和容器数据存储位置
指定镜像和容器存放路径的参数是--graph=/var/lib/docker,其默认存储位置为/var/lib/docker, Docker 的配置文件可以设置大部分的后台进程参数,在各个操作系统中的 ...