Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The other answers covered the namespace issue, but I'll add that I found that the context:property-placeholder tag needed to be between "spring:beans" tags. Here's an example that presumes that the properties file sets a property named "jmsBrokerURL":</p> <pre><code>&lt;mule xmlns="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt; &lt;spring:beans&gt; &lt;context:property-placeholder location="C:/path/to/file/settings.properties" /&gt; &lt;spring:bean name="myConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"&gt; &lt;spring:property name="brokerURL" value="${jmsBrokerURL}" /&gt; &lt;/spring:bean&gt; &lt;/spring:beans&gt; &lt;flow name="MyFlow" doc:name="MyFlow"&gt; &lt;!-- Flow configuration here. --&gt; &lt;/flow&gt; &lt;/mule&gt; </code></pre> <p>An alternate method of reading properties (and one I prefer) is to use the Spring "util:properties" tag to read properties into a Properties bean which you then refer to using Spring EL. Watch out in this case that you use the Spring EL "#{}" notation instead of "${}" to reference the object and its variables. Here's the above example modified for that technique:</p> <pre><code>&lt;mule xmlns="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"&gt; &lt;spring:beans&gt; &lt;util:properties id="myConfig" location="C:/path/to/file/settings.properties" /&gt; &lt;spring:bean name="myConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"&gt; &lt;spring:property name="brokerURL" value="#{myConfig.jmsBrokerURL}" /&gt; &lt;!-- Note the pound (hash) symbol. --&gt; &lt;/spring:bean&gt; &lt;/spring:beans&gt; &lt;flow name="MyFlow" doc:name="MyFlow"&gt; &lt;!-- Flow configuration here. --&gt; &lt;/flow&gt; &lt;/mule&gt; </code></pre> <p>I like this latter approach mainly because I can deal with multiple properties files and included application context files more easily. The context:property-placeholder tag can be problematic when dealing with either multiple property files or when including an application context file within another.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload