Maven的几个常用plugin
出自:https://www.cnblogs.com/zhangxh20/p/6298062.html
maven-compiler-plugin
编译Java源码,一般只需设置编译的jdk版本
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.6.0</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
或者在properties设置jdk版本
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
- </properties>
maven-dependency-plugin
用于复制依赖的jar包到指定的文件夹里
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.10</version>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>package</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}/lib</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
maven-jar-plugin
打成jar时,设定manifest的参数,比如指定运行的Main class,还有依赖的jar包,加入classpath中
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>/data/lib</classpathPrefix>
- <mainClass>com.zhang.spring.App</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
maven-antrun-plugin
在maven中运行Ant任务,比如在打包阶段,对文件进行复制
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.7</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <target name="copy">
- <delete>
- <fileset dir="target" includes="*.properties"></fileset>
- </delete>
- <copy todir="target">
- <fileset dir="files"></fileset>
- </copy>
- </target>
- </configuration>
- </execution>
- </executions>
- </plugin>
wagon-maven-plugin
用于一键部署,把本地打包的jar文件,上传到远程服务器上,并执行服务器上的shell命令
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>wagon-maven-plugin</artifactId>
- <version>1.0</version>
- <configuration>
- <serverId>crawler</serverId>
- <fromDir>target</fromDir>
- <includes>*.jar,*.properties,*.sh</includes>
- <url>sftp://59.110.162.178/home/zhangxianhe</url>
- <commands>
- <command>chmod 755 /home/zhangxianhe/update.sh</command>
- <command>/home/zhangxianhe/update.sh</command>
- </commands>
- <displayCommandOutputs>true</displayCommandOutputs>
- </configuration>
- </plugin>
tomcat7-maven-plugin
用于远程部署Java Web项目
- <plugin>
- <groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
- <version>2.2</version>
- <configuration>
- <url>http://59.110.162.178:8080/manager/text</url>
- <username>linjinbin</username>
- <password>linjinbin</password>
- </configuration>
- </plugin>
maven-shade-plugin
用于把多个jar包,打成1个jar包
一般Java项目都会依赖其他第三方jar包,最终打包时,希望把其他jar包包含在一个jar包里
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.4.3</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer
- implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <manifestEntries>
- <Main-Class>com.meiyou.topword.App</Main-Class>
- <X-Compile-Source-JDK>${maven.compile.source}</X-Compile-Source-JDK>
- <X-Compile-Target-JDK>${maven.compile.target}</X-Compile-Target-JDK>
- </manifestEntries>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
maven-source-plugin
将项目源代码打包成一个jar包(是java文件打包)
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <configuration>
- <attach>true</attach>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
maven-assembly-plugin
根据package.xml生成一个特别的包
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <appendAssemblyId>false</appendAssemblyId>
- <descriptors>
- <descriptor>src/main/build/package.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
Maven的几个常用plugin的更多相关文章
- (五)Maven目录结构及常用命令说明
前面提到的部分知识有涉及到Maven目录结构与Maven常用的一些命令,在这里专门给大家做个简单的介绍. 1.Maven目录结构说明 Maven总体目录结构如下图: bin目录:该目录包含了mvn运行 ...
- Maven系列(一)plugin
Maven系列(一)plugin maven-compiler-plugin 使用 mvn compile 命令,出现错误: 编码 GBK 的不可映射字符而不能编译.这是因为代码或注释中存在中文引起的 ...
- Maven 教程(5)— Maven目录结构及常用命令说明
原文地址:https://blog.csdn.net/liupeifeng3514/article/details/79543159 1.Maven目录结构说明 Maven总体目录结构如下图: bin ...
- maven一键构造及常用命令
maven一键构造及常用命令 1.maven的一键构建 我们不再使用本地的Tomcat对项目进行编译.测试.运行.打包.安装.部署等一系列过程,而是使用maven自身集成的Tomcat插件来完成这些操 ...
- maven profiles、filters、resources学习笔记 及 常用 plugin demo
这里只记了学习以下博客后,自己做的一个总结. 来源:http://blog.csdn.net/fengchao2016/article/details/72726101 profiles定义了一些不同 ...
- JAVA记录-maven JDK配置和常用操作
1.pom.xml加入(JDK编译器配置) <build> <finalName>项目名</finalName> <plugins> <plugi ...
- Maven构建应用程序常用配置(转)
来自:http://shiyanjun.cn/archives/180.html 使用Maven来构建应用程序,可以非常方便地管理应用相关的资源.众所周知,应用程序中涉及到的一些依赖关系,如Java应 ...
- maven Error resolving version for plugin 'org.apache.maven.plugins:maven-eclipse-plugin' from the repositories 解决
报错:Error resolving version for plugin 'org.apache.maven.plugins:maven-eclipse-plugin' from the repos ...
- Maven中pom.xml常用元素说明
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
随机推荐
- 使用lua graphql 模块让openresty 支持graphql api
graphql 是一个很不错的api 查询标准语言,已经有一个lua 的版本支持graphql 项目使用docker&&docker-compose 运行 环境准备 模块安装 lu ...
- mysql 变量名称的使用不当的一个错误
对于开发来说重要的是按照规范进行开发. 昨天自己在进行开发测试的时候,编写mysql 的一个存储过程 ,代码是比较简单的 就是根据名称查询对应的数据并返回 DELIMITER // CREATE PR ...
- jquery append、prepend、before等等
1.jQuery append() 方法 jQuery append() 方法在被选元素的结尾插入内容. 实例 复制代码代码如下: $("p").append("Some ...
- java 多线程之:join() 方法
join()介绍 join() 定义在java.lang.Thread中. join() 的作用:让"主线程"等待"子线程"结束之后才能继续运行.
- git 知识点
git 删除远程已经推送过的文件或者文件夹 git rm -r --cached [文件或文件夹] git status git add . git commit -m '删除远程仓库文件,本地仓库和 ...
- gitlab使用外部的postgresql、外部的redis服务器
postgresql创建用户 su - postgres psql create role gitlab login encrypted password 'pass';\du ;显示用户 postg ...
- ES(1): Creat linux VM on Azure
本章记录在ES集群之前的环境准备工作,主要包含的内容如下: 目录: 创建linux虚拟机 启用root用户 创建linux虚拟机 首先创建一个云服务 按向导创建云服务名称,如下 创建虚拟机, 第二步: ...
- 杂项:Nuget
ylbtech-杂项:Nuget Nuget是一个.NET平台下的开源的项目,它是Visual Studio的扩展.在使用Visual Studio开发基于.NET Framework的应用时,Nug ...
- MySQL excel导入
说明: 1 因在测试发现如果用SQLyog导入数据需要下载excel驱动,因而选择Navicat 2 之前选择excel文件为xlsx 发现Navicat识别不了,因而转存为xls文件,测试OK 1 ...
- 1062 Talent and Virtue (25 分)
1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a history ...