wyx2000
wyx2000

Reputation: 83

Mulesoft doesn't read properties from right file?

I had mavenize my project, trying to find the right way to handle DEV, Pre-Production and Production properties. I created a property named mule.env, and added context property like

<context:property-placeholder location="${mule.env}.properties"/>

I have mule-app.properties and mule-deploy.properties, their content like below

mule-app.properties

c3=c3.p1
c2=c2.p1
c1=c1.p1
mule.env=dev

mule-deploy.properties

c4=c4.p2
c3=c3.p2
redeployment.enabled=true
c2=c2.p2
encoding=UTF-8
config.resources=test-config.xml
domain=default

I have a dev.properties under resources,

dev.properties

c1=c1.dev
c2=c2.dev
c3=c3.dev
c4=c4.dev

And I have a flow to show properties in set payload

<flow name="test-configFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/"  doc:name="HTTP"/>
    <set-payload value="c1:${c1} &lt;br/&gt; c2:${c2} &lt;br/&gt; c3:${c3}  &lt;br/&gt; ${mule.env}" mimeType="text/html" doc:name="Set Payload"/>
</flow>

The result is

c1:c1.p1 
c2:c2.p1 
c3:c3.p1 
dev

I expect result like

c1:c1.dev
c2:c2.dev
c3:c3.dev
dev

since the properties should be from the dev.properties

Any idea?

Upvotes: 0

Views: 381

Answers (1)

Anirban Sen Chowdhary
Anirban Sen Chowdhary

Reputation: 8311

This is obvious since in your mule-app.properties contains:

c3=c3.p1
c2=c2.p1
c1=c1.p1
mule.env=dev

this is overriding the value of dev.properties under resources
Solution : remove

c3=c3.p1
c2=c2.p1
c1=c1.p1

from mule-app.properties. So, you mule-app.properties should only contain:

mule.env=dev

and no other values

Upvotes: 1

Related Questions