Maven常用命令

一、常用命令:

二、 命令参数:

上 ⾯ 列举的只是 ⽐ 较通 ⽤ 的命令,其实很多命令都可以携带参数以执 ⾏ 更精准的任务。

1. -D 传⼊属性参数

例如:
mvn package -Dmaven.test.skip=true
以 -D 开头,将 maven.test.skip 的值设为 true , 就是告诉 maven 打包的时候跳过单元测试。同
理, mvn deploy-Dmaven.test.skip=true 代表部署项 ⽬ 并跳过单元测试。

2. -P 使⽤指定的Profile配置

⽐ 如项 ⽬ 开发需要有多个环境, ⼀ 般为开发,测试,预发,正式 4 个环境,在 pom.xml 中的配置如
下:
<profiles>
<profile>
<id> dev </id>
<properties>
<env> dev </env>
</properties>
<activation>
<activeByDefault> true </activeByDefault>
</activation>
</profile>
<profile>
<id> qa </id>
<properties>
<env> qa </env>
</properties>
</profile>
<profile>
<id> pre </id>
<properties>
<env> pre </env>
</properties>
</profile>
<profile>
<id> prod </id>
<properties>
<env> prod </env>
</properties>
</profile>
</profiles>
......
<build>
<filters>
<filter> config/${env}.properties </filter>
</filters>
<resources>
<resource>
<directory> src/main/resources </directory>
<filtering> true </filtering>
</resource>
</resources>
......
</build>
profiles 定义了各个环境的变量 id , filters 中定义了变量配置 ⽂ 件的地址,其中地址中的环境
变量就是上 ⾯ profile 中定义的值, resources 中是定义哪些 ⽬ 录下的 ⽂ 件会被配置 ⽂ 件中定义的变
量替换。
通过 maven 可以实现按不同环境进 ⾏ 打包部署,例如:
mvn package -Pdev -Dmaven.test.skip=true
表示打包本地环境,并跳过单元测试

相关推荐
zhongben_keji4 小时前
家政小程序开发全解:经营模式、品类矩阵、派单约束与信用核验
线性代数·矩阵·apache
peach1 天前
同样是装依赖,为什么 npm 长成 node_modules,Maven 长成 .m2
npm·node.js·maven
屈冠成1 天前
ShopXO商城系统测试报告
开发语言·spring·maven·lua
weixin_177297220691 天前
二手旧物回收小程序先要解决的不是下单,是“上门之后价格变了怎么办“
小程序·apache
努力变的更好1 天前
H5与小程序之间的回调
前端·小程序·apache
七夜zippoe1 天前
Agent 网关设计:统一入口、智能路由与负载均衡
运维·ai·log4j·负载均衡·agent·网关设计
十碗饭吃不饱3 天前
Apache POI 踩坑:setFontFamily 二次设置字体不生效、样式残留问题深度解析
java·word·apache
jianxuan3 天前
Spring Boot + Maven 接入 Allatori:从普通打包到可选混淆发布
spring boot·python·maven
伞伞悦读4 天前
Maven 下载与配置教程(新手友好版)
maven
心随_风动4 天前
Ubuntu系统安装Apache服务教程
linux·ubuntu·apache