Maven的几个常用Plugin
一. 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.rz.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://xx.xx.xx.xx/home/rz</url><commands><command>chmod 755 /home/rz/update.sh</command><command>/home/rz/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://xx.xx.xx.xx:8080/manager/text</url><username>rz</username><password>rz</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><transformerimplementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"><manifestEntries><Main-Class>com.rz.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的几个常用Plugin相关推荐
- Maven的build生命周期和常用plugin
文章目录 简介 lifecycle和Phases Phases和Goals 常用plugin介绍 maven-dependency-plugin maven-jar-plugin 总结 简介 Mave ...
- Maven 配置文件 POM 的常用插件配置代码
Maven 配置文件 POM 的常用插件配置代码 普通 将 Maven 多模块依赖集成打进一个 JAR 包(方法 1) 将 Maven 多模块依赖集成打进一个 JAR 包(方法 2) 生成单入口类 J ...
- (五)Maven目录结构及常用命令说明
前面提到的部分知识有涉及到Maven目录结构与Maven常用的一些命令,在这里专门给大家做个简单的介绍. 1.Maven目录结构说明 Maven总体目录结构如下图: bin目录:该目录包含了mvn运行 ...
- Maven 配置文件 POM 的常用依赖配置代码
Maven 配置文件 POM 的常用依赖配置代码 Lombok 测试 Junit 5 日志 Log4j2 & SLF4J & Lombok Spring Bean Spring Boo ...
- maven项目的Archetype常用选择
maven项目的Archetype常用选择 在使用idea构建项目时候, 会有如下界面: 这里的Archetype表是使用哪一个模板来初始化我们的项目:简单的说,Archetype是Maven工程的模 ...
- IDEA中Maven配置出现Cannot resolve plugin org.apache.maven.pluginsmaven-resources-plugin3.1.0
IDEA中Maven配置出现Cannot resolve plugin org.apache.maven.plugins:maven-resources-plugin:3.1.0 注意修改配置文件与仓 ...
- java maven plugin_Maven的几个常用plugin
maven-compiler-plugin 编译Java源码,一般只需设置编译的jdk版本 org.apache.maven.plugins maven-compiler-plugin 3.6.0 1 ...
- Maven之pom.xml常用标签解析及镜像配置
前言 Maven仅仅是个打包工具而已,个人觉得没有太大必要花费在打包工具上,这里就列举一下个人觉得会常用标签的使用就好了,原理啥的基本就不太会去深度了解了,如果以后遇到需了解Maven工作原理的工作的 ...
- maven关闭检验_Maven常用命令:
Maven库: Maven依赖查询: 一,Maven常用命令: 1. 创建Maven的普通Java项目: mvn archetype:create -DgroupId=packageName -Dar ...
最新文章
- 干货 | 浅谈 Softmax 函数
- python面向对象总结_python面向对象总结
- i是j的倍数c语言编程,【图片】【编程!】记录我C语言的一步步【极度恐慌漫画吧】_百度贴吧...
- 渗透知识-常用DOS命令windows
- EV3 直接命令 - 第一课 无为的艺术
- LeetCode之Reverse Integer
- 用VC写Assembly代码(7)--在Visual C++中使用内联汇编
- 将字符串转换为全角或半角
- VALSE学习(十六): Visual Question Generation and Answering-视觉问题生成和视觉问题
- RUP---统一软件开发过程
- ILSpy .NET反编译工具下载地址
- KK 在 68 岁生日时给出的 68 条建议[翻译]#yyds干货盘点#
- iPhone 小技巧/实用功能
- 文件批量改名-bat操作
- 植物神经紊乱引起的焦虑、烦躁怎么办?
- Windows 10 屏幕亮度调节快捷方法
- linux iconv_open 多线程 安全,雨林木风弃Windows推Linux开源操作系统
- 短信平台源码专业版功能介绍(可接入任何线路的短信接口)|移讯云短信系统
- 竞品分析——崩坏3 战双帕弥什
- [Leetcode] 33. Search in Rotated Sorted Array 解题报告