如何访问 mule 配置文件中的 POM 文件属性?

How can I access POM file properties inside mule configuration files?

假设我需要访问我的 POM 文件的属性标记内的 groupId。我如何在我的 mule 配置文件中访问它。

我试图像 ${pom.properties.app.groupId} 那样访问它,但没有成功。有什么想法吗?

这个问题之前曾在 Mule 4 : Is there a way to refer Maven POM properties from a Mule Flow? 和其他人那里被问过。

我会在这里重复我的回答,因为 Whosebug 不允许我将这个标记为重复。

That's because Maven properties do not exists anymore when the application is executed.

You can use some Maven plugins to replace values in a properties files, that can be used inside the application. For example the Maven Resources plugin. Be careful of not override properties inside other files, like the XML Mule configurations of the application.

更新:我创建了一个示例:

假设您有一个名为 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