maven常用插件整理
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven常用插件整理相关的知识,希望对你有一定的参考价值。
1. 依赖管理插件:maven-dependency-plugin, 详见: https://maven.apache.org/plugins/maven-dependency-plugin/
通过该插件可以对被依赖组件进行复制,解压等一系列操作,特别是在多模块化项目中配置Spring自动扫描时该插件非常有用。
配置示例:
1 <build> 2 <plugins> 3 <!-- 将依赖模块的jar包文件提取出来放到指定位置 --> 4 <plugin> 5 <groupId>org.apache.maven.plugins</groupId> 6 <artifactId>maven-dependency-plugin</artifactId> 7 <executions> 8 <execution> 9 <id>unpack</id> 10 <phase>prepare-package</phase> 11 <goals> 12 <goal>unpack</goal> 13 </goals> 14 <configuration> 15 <artifactItems> 16 <artifactItem> 17 <groupId>com.xxx</groupId> 18 <artifactId>xxx-xxx</artifactId> 19 <version>1.0.0</version> 20 <type>jar</type> 21 <includes>**/*.class</includes> 22 <overWrite>false</overWrite> 23 <outputDirectory>${project.build.directory}/classes</outputDirectory> 24 </artifactItem> 25 </artifactItems> 26 </configuration> 27 </execution> 28 </executions> 29 </plugin> 30 </plugins> 31 </build>
2. 打包插件: maven-assembly-plugin, 详见: http://maven.apache.org/plugins/maven-assembly-plugin/
maven项目压缩打包,可以将项目安装包打包为一个规范,专业的格式进行发布。
配置示例:
1 <build> 2 <plugins> 3 <!-- 部署打包: 通过maven-assembly插件压缩为tar包进行发布 --> 4 <plugin> 5 <artifactId>maven-assembly-plugin</artifactId> 6 <configuration> 7 <!-- not append assembly id in release file name --> 8 <appendAssemblyId>false</appendAssemblyId> 9 <descriptors> 10 <descriptor>assembly.xml</descriptor> 11 </descriptors> 12 <finalName>xxx-${project.version}</finalName> 13 <outputDirectory>${basedir}/release</outputDirectory> 14 </configuration> 15 <executions> 16 <execution> 17 <id>make-assembly</id> 18 <phase>verify</phase> 19 <goals> 20 <goal>single</goal> 21 </goals> 22 </execution> 23 </executions> 24 </plugin> 25 </plugins> 26 </build>
3. 资源插件: maven-resources-plugin, 详见: https://maven.apache.org/plugins/maven-resources-plugin/
以上是关于maven常用插件整理的主要内容,如果未能解决你的问题,请参考以下文章