我需要做的是从 java 代码中的 pom.xml 检索项目版本。
我目前正在按照官方文档的建议使用该代码段:
@ConfigProperty(name = "version")
public String version;
application.properties:
version=${quarkus.platform.version}
因此,似乎 pom.xml 属性无法在没有任何样板的情况下通过 application.properties 获得。有什么想法吗?
最佳答案
尝试一下我发布的内容:quarkus read pom.xml properties
pom.xml:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/application.properties</include>
</includes>
</resource>
</resources>
在application.properties中使用版本属性:
quarkus.version=${quarkus.platform.version}
然后将其用作配置属性:
@ConfigProperty(name = "quarkus.version")
String version;
关于java - Quarkus/microprofile读取pom.xml属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59406363/