如何使用pom.xml更新属性文件中的环境值

问题描述 投票:0回答:1

我在configs / Configuration.properties中具有configuration.properties,其中我的网址路径=http://finacial/dev3/apihttp:// financial / {env} / api我想根据pom.xml中设置的环境属性从pom.xml加载环境值以替换dev 3。

java maven properties pom.xml bdd
1个回答
0
投票

您可以使用Maven filter plugin,它正是这样做的。考虑到目的,它的名字有点奇怪,但是我们对此没有太多选择。

变量可以包含在您的资源中。这些变量用$ {...}分隔符表示,可以来自系统属性,项目属性,过滤器资源和命令行。

如果您的pom中有属性url

<properties>
     <url>abc</ulr>  
</properties>

并且您的.properties文件包含值${url},并且将该文件包含在pom的resource部分中,然后在发出${url}时,abc将在构建目标位置的输出文件中替换为mvn resources:resources ]

<resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
</resource>
© www.soinside.com 2019 - 2024. All rights reserved.