【发布时间】:2020-07-11 19:41:33
【问题描述】:
假设我需要访问我的 POM 文件的属性标签内的 groupId。如何在我的 mule 配置文件中访问它。
我尝试像 ${pom.properties.app.groupId} 一样访问它,但没有成功。有什么想法吗?
【问题讨论】:
假设我需要访问我的 POM 文件的属性标签内的 groupId。如何在我的 mule 配置文件中访问它。
我尝试像 ${pom.properties.app.groupId} 一样访问它,但没有成功。有什么想法吗?
【问题讨论】:
这个问题之前已经在Mule 4 : Is there a way to refer Maven POM properties from a Mule Flow? 和其他人问过。
我将在这里重复我的答案,因为 Stackoverflow 不允许我将此标记为重复。
这是因为当 Maven 属性不再存在时 应用程序被执行。
您可以使用一些 Maven 插件来替换属性中的值 文件,可以在应用程序内部使用。例如 Maven Resources plugin。注意不要覆盖其他内部的属性 文件,例如应用程序的 XML Mule 配置。
更新:我创建了一个示例:
假设您有一个名为 config.properties 的属性文件,您想在其中放置 Maven 属性 name 的值:
a=1
b=${some.property}
然后您可以在该文件中启用 Maven 属性过滤:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>config.properties</include>
</includes>
</resource>
</resources>
...
我的博客对这个例子有更长的解释:https://medium.com/@adobni/using-maven-properties-as-mule-properties-3f1d0db62c43
【讨论】: