如何在编写 MUnit 时加载 mule-app.properties
how to load mule-app.properties while writing MUnit
我正在编写一个 MUnit,并且在 mule-app.properties 文件中提到了 HttpListerner 的端口。
当我使用 getConfigResources 加载流程时,它没有加载。
还有什么我需要做的吗?
您可以在以下位置获取配置 mule 应用程序属性的完整分步解决方案
https://docs.mulesoft.com/mule-user-guide/v/3.7/configuring-properties
尝试使用 Logger 组件加载它,例如,如果您将 http 侦听器配置放在 mule-app.properties 中,您可以通过此示例 xml 配置访问它(也不是 HttpListener HttpListerner)
<logger message="${HttpListener}" level="INFO" doc:name="Log HttpListener Value"/>
您的 mule-app.properties 文件包含:
HttpListener="configuration example, url, host, port"
希望对您有所帮助。
也许您可以尝试在 Munit Flow 中使用 属性-placeholder 元素加载属性,如下所示:
<context:property-placeholder location="mule-app.test.properties"/>
我认为最好配置每个流所需的属性,就像在 Munit 流开始时这样
<global-property name="prop1" value="value1"/>
<global-property name="prop2" value="value2"/>
然后您可以正常访问它们 属性。
您可以找到文档 here
希望对您有所帮助。
/T
这个成功了。
在 getConfigResources()
中设置系统 属性
System.setProperty("http.port", "port_value");
我正在编写一个 MUnit,并且在 mule-app.properties 文件中提到了 HttpListerner 的端口。 当我使用 getConfigResources 加载流程时,它没有加载。 还有什么我需要做的吗?
您可以在以下位置获取配置 mule 应用程序属性的完整分步解决方案 https://docs.mulesoft.com/mule-user-guide/v/3.7/configuring-properties
尝试使用 Logger 组件加载它,例如,如果您将 http 侦听器配置放在 mule-app.properties 中,您可以通过此示例 xml 配置访问它(也不是 HttpListener HttpListerner)
<logger message="${HttpListener}" level="INFO" doc:name="Log HttpListener Value"/>
您的 mule-app.properties 文件包含:
HttpListener="configuration example, url, host, port"
希望对您有所帮助。
也许您可以尝试在 Munit Flow 中使用 属性-placeholder 元素加载属性,如下所示:
<context:property-placeholder location="mule-app.test.properties"/>
我认为最好配置每个流所需的属性,就像在 Munit 流开始时这样
<global-property name="prop1" value="value1"/>
<global-property name="prop2" value="value2"/>
然后您可以正常访问它们 属性。
您可以找到文档 here
希望对您有所帮助。
/T
这个成功了。
在 getConfigResources()
中设置系统 属性System.setProperty("http.port", "port_value");