【问题标题】:Maven Property file plugin replaces whole content of property file while writingMaven 属性文件插件在写入时替换属性文件的全部内容
【发布时间】:2015-04-21 23:45:45
【问题描述】:

我正在使用 Maven 属性文件插件 (goal write-project-properties) 将项目属性写入我的 Java 项目的属性文件中。但是,除了我要更新的属性之外,我的属性文件还包含更多属性。

例如。我的道具文件的内容是

a=123
b=345
c=567

我想使用属性文件插件只更新 b 和 c 值。我的 POM.xml 包含

<properties>
   <b>789</b>
   <c>890</c> 
</properties>

但是,在运行 mvn properties:write-project-properties 时,它会更新 b 和 c 值并删除“a”。有没有办法可以保留 a 并只更新 b 和 c 值?

谢谢

【问题讨论】:

    标签: java maven maven-3 pom.xml


    【解决方案1】:

    如果您想替换文件中的某些值,这不是正确的插件。

    您最好使用resources plugin,在属性文件中放置占位符,这些占位符将被 pom 文件中相应定义的属性替换。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-06
      • 2014-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      相关资源
      最近更新 更多