简体   繁体   中英

read same key from different properties file in mule

I want to read a key called 'age' from a one properties file and a key called 'age' (same key name) from another properties file in mulesoft ESB. For one properties file, it is accessible using ${name}. But how to read the same key from different properties file in Mule ESB?

Using property placeholder, each file will be loaded in turn, overwriting duplicate properties from the first one. So in your case, properties defined in the second file will take precedence.

Not sure why you need the different vales from each file. But if you have to and they have to have the same name,you could load the duplicate file directly into a map using Spring like so:

 <spring:beans>
        <spring:bean id="appProps" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <spring:property name="singleton" value="true"/>
            <spring:property name="location" value="classpath:application.properties"/>
        </spring:bean>
    </spring:beans>

And access it dynamically in your flow using MEL similar to:

 <logger message="My prop #[app.registry.appProps['age']]" level="INFO" />

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