转载:https://blog.csdn.net/yy193728/article/details/72847122
-D代表(Properties属性)
用法:
mvn -DpropertyName=propertyValue clean package
如果propertyName不存在pom.xml,它将被设置
如果propertyName已经存在pom.xml,其值将会传递给参数
要发送多个变量,请使用多个空格分隔符加-D:
mvn -DpropA=valueA -DpropB=valueB -DpropC=valueC clean package
例:
如果你的pom.xml如下:
<properties>
<theme>myDefaultTheme</theme>
</properties>
执行以下命令:
mvn -Dtheme=halloween clean package
会有如下效果:
<properties>
<theme>halloween</theme>
</properties>
-P代表(Profiles配置文件)
<profiles>指定的<id>中,可以通过-P进行传递或者赋值
例如:
pom.xml如下:
<profiles>
<profile>
<id>test</id>
...
</profile>
</profiles>
可以执行以下命令出触发该配置:
mvn test -Ptest
如果pom.xml如下:
<profile>
<id>test</id>
<activation>
<property>
<name>env</name>
<value>test</value>
</property>
</activation>
...
</profile>
执行以下命令触发该配置:
mvn test -Penv=test