简体   繁体   中英

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

Lets say I needed to access a groupId inside the properties tag of my POM file. How can i access that in my mule configuration file.

I tried to access it like ${pom.properties.app.groupId} but it didn't work. Any ideas?

在此处输入图像描述 在此处输入图像描述

This question has been asked before at Mule 4: Is there a way to refer Maven POM properties from a Mule Flow? and probably others.

I'll repeat my answer here because Stackoverflow doesn't allow me to mark this one as a duplicate.

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.

Update: I have created an example:

Assume that you have a properties file called config.properties in which you want to put the value of Maven property name :

a=1
b=${some.property}

Then you can enable Maven property filtering in just that file with:

<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>
    ...

My blog has a longer explanation of this example: https://medium.com/@adobni/using-maven-properties-as-mule-properties-3f1d0db62c43

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM