I have a mule application built using mule apikit. The mule-app.properties file contains below property:
orig.db.url=jdbc:db2://mmrs001.nmd.net:1004/dudu:user=abc43;password=xxxx;
The custom properties file src/main/resources/dev.properties contains below property:
db.url=${orig.db.url}
And, the mule configuration xml file contains below property-placeholder:
<context:property-placeholder location="dev.properties"/>
Now, when I deploy it locally everything works fine and I am able to run the flow. But, at the same time when I deploy on Cloudhub it gives me below exception:
Invalid bean definition with name 'get:/total_amount:total_amount-db-config' defined in null: Could not resolve placeholder 'orig.db.url' in string value "jdbc:db2://mmrs001.nmd.net:1004/dudu:user=abc43;password=xxxx;"
I am unable to understand what am I missing here?
By default when deploying to cloudhub all properties from the mule-app.properties should appear in the properties tab. Did you not see them when you deployed the first time?
The mule-app.properties will get added to system properties instead of classpath properties. We can't refer to system properties from property files added to classpath. We need to move these properties to classpath to resolve these in runtime.
One way to override this behaviour by importing mule-app.properties using:
It tells spring to load properties in respective order. So, first mule-app.properties gets loaded and then dev.properties.
But, its not the best practice to include the mule-app.properties file in the classpath. Best way is to remove the dev properties from mule-app.properties and put it inside dev.properties.
How did you deploy to CloudHub? If you used the deployment tool from Anypoint Studio you have an option to set properties before deployment.