Maven 的默认构建配置文件

我已经在 Maven 项目中添加了侧写。

        <profile>
<id>da</id>
</profile>
<profile>
<id>live</id>
</profile>
<profile>
<id>dev</id>
</profile>

当我在不指定构建配置文件的情况下给出命令 mvn clean install时。我需要的 Dev配置文件是默认构建。

我怎么才能做到呢?

63734 次浏览

通过使用属性 activeByDefault,您将能够在 Maven 中选择默认配置文件,而不会使用-P 参数选择其他配置文件。

<profiles>
<profile>
<id>da</id>
</profile>
<profile>
<id>live</id>
</profile>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
    

参见 概要文档简介

也可以通过运行

mvn clean install -Pprod

或者

mvn clean install -Pdev