【问题标题】:How can I access POM file properties inside mule configuration files?如何访问 mule 配置文件中的 POM 文件属性?
【发布时间】:2020-07-11 19:41:33
【问题描述】:

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

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

【问题讨论】:

    标签: pom.xml mulesoft mule4


    【解决方案1】:

    这个问题之前已经在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

    【讨论】:

    • 感谢您的回答。一请求。你能指点我这个示例项目吗?
    • 我添加了一个例子
    猜你喜欢
    • 2018-08-09
    • 1970-01-01
    • 2013-01-23
    • 2017-01-29
    • 2011-11-26
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多