gpt4 book ai didi

maven-2 - 设置自定义 Maven 2 属性的默认值

转载 作者:行者123 更新时间:2023-11-30 12:03:33 25 4
gpt4 key购买 nike

我有一个带有插件的 Maven pom.xml,我希望能够在命令行上控制它。否则一切正常,除了即使在网上搜索了一段时间后我也不知道如何为我的控件属性设置默认值:

<plugin>
...
<configuration>
<param>${myProperty}</param>
</configuration>
...
</plugin>

所以如果我用

运行Maven
mvn -DmyProperty=something ...

一切正常,但我想在没有 -DmyProperty=... 开关的情况下也为 myProperty 分配一个特定值。如何做到这一点?

最佳答案

您可以在 <build>/<properties> 中定义属性默认值或在如下所示的配置文件中。当您在命令行上使用 -DmyProperty=anotherValue 提供属性值时然后它将覆盖 POM 中的定义。也就是说,POM 中属性值的所有定义都只设置了属性的默认值。

<profile>
...
<properties>
<myProperty>defaultValue</myProperty>
</properties>
...
<configuration>
<param>${myProperty}</param>
</configuration>
...
</profile>

关于maven-2 - 设置自定义 Maven 2 属性的默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57684667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com