如何将 .properties 文件中的数据存储在 Mulesoft Anypoint Studio 的变量中?
How to store data from a .properties file in a variable in Mulesoft Anypoint Studio?
我有几个包含一些数据的 .properties 文件。如何将 属性 的特定值从 属性 文件之一写入变量?
有以下三种方法可以执行此问题陈述。
1.Reading a properties file using ${Key} expression
2.Reading a properties file using ![p[‘Key’]] expression
3.Reading a properties file using p() function from DataWeave
While according to your need, I have used the first approach. Please go through the following code. I think this will resolve your problem.
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<context:property-placeholder location="propread.properties"/>
<flow name="propreadFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/propread" doc:name="HTTP"/>
<logger message=""Flow Started"" level="INFO" doc:name="Logger"/>
<set-variable variableName="prop" value="${prop.read}" doc:name="Variable"/>
<logger message="#[flowVars.prop]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Please create one property file under src/main/resources with the name propread.properties and copy this ( prop.read=HelloMule ) into the file and run the above code. You will get the solution.
我有几个包含一些数据的 .properties 文件。如何将 属性 的特定值从 属性 文件之一写入变量?
有以下三种方法可以执行此问题陈述。
1.Reading a properties file using ${Key} expression
2.Reading a properties file using ![p[‘Key’]] expression
3.Reading a properties file using p() function from DataWeave
While according to your need, I have used the first approach. Please go through the following code. I think this will resolve your problem.
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<context:property-placeholder location="propread.properties"/>
<flow name="propreadFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/propread" doc:name="HTTP"/>
<logger message=""Flow Started"" level="INFO" doc:name="Logger"/>
<set-variable variableName="prop" value="${prop.read}" doc:name="Variable"/>
<logger message="#[flowVars.prop]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Please create one property file under src/main/resources with the name propread.properties and copy this ( prop.read=HelloMule ) into the file and run the above code. You will get the solution.