gpt4 book ai didi

maven-2 - Maven 过滤资源并添加项目版本

转载 作者:行者123 更新时间:2023-12-04 12:14:13 26 4
gpt4 key购买 nike

这是将项目版本写入文件的简单过滤方法。

<build>
<resources>
<resource>
<directory>src/main/webapp</directory>
<includes>
<include>**/*.version</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>

这是项目结构(省略了无趣的部分)
├───src
│ └───main
│ ├───java
│ │ └─── [...]
│ └───webapp
│ ├───META-INF
│ └───WEB-INF
│ ├───cfg
│ └───portal.version
└─── pom.xml
portal.version的内容
${project.version}

这应该替换为 pom.xml 的工件版本,但不幸的是没有任何 react 。怎么了?先感谢您

最佳答案

当您指定资源元素时,结果过滤内容将复制到目标/类文件夹中。要过滤 Web 应用程序资源,您可以配置 maven-war-plugin。

虽然要获取版本,但在大多数情况下,最好读取应用程序中的标准 Maven 属性文件,例如META-INF\maven\<groupId>\<artifactId>\pom.properties

关于maven-2 - Maven 过滤资源并添加项目版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3779830/

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