Maven 使用经验总结

本文介绍了Maven的使用技巧和相关插件功能。包括列出阶段插件绑定、有效POM,指出profile配置继承规则,dependencyManagement和pluginManagement节点内容继承方式,resouces节点的filter功能,还提及取消阶段插件绑定的方法,以及使用maven - assembly - plugin生成可运行jar包和用其他插件执行任意命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. list phase-plugin bindings , either of them will work.

 mvn help:describe  -Dcmd=<phase> -Darguments_to_phase

mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list-phase -Dbuildplan.tasks=<phase>  //this one is preferred.

2. list effective pom

mvn help:effective-pom

2.pom里面定义的 profile会自动继承默认pom的配置,默认pom的配置优先执行,如果某个profile的配置不生效,可以检查下默认的pom配置

3. dependencyManagement, pluginManagement节点中配置的内容可以被child POM 继承,child POM中必须引用对应的plugin或者dependency才能起作用,或者是lifecycle的默认binding。

4. resouces 节点有个功能叫做filter,意思是对定义的resouces中的所有文件进行变量替换,替换的变量可以来自maven命令行,其他文件,或者是settings.xml等等。

5. 取消某个phase-plugin binding, 设置对应id的goal的phase为none,如下所示

<plugin>
	<artifactId>maven-resources-plugin</artifactId>
	<version>2.6</version>
	<executions>
		<execution>
			<id>default-resources</id>
			<phase>none</phase>
		</execution>
	</executions>
</plugin>

6. 可以使用maven-assembly-plugin插件生成一个runnable jar package, 支持复杂的打包方式

7. 可以使用maven-antrun-plugin,exec-maven-plugin 插件执行任意命令,

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值