我在尝试将 Spring 组件添加到 Mule Flow 时收到错误消息。这应该是一个常见的用户案例,但我无法找到正确的文档或示例。提前致谢。
以下是原始配置并且工作正常:
<flow name="ApplicationEndpoint">
<inbound-endpoint address="server:port/JSONAPI/"/>
<jersey:resources>
<component>
<spring-object bean="myJerseyService"/>
</component>
</jersey:resources>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<flow-ref name="ErrorHandling" doc:name="Flow Reference"/>
</catch-exception-strategy>
</flow>
我只是想添加一个新组件来进行一些后处理。当我尝试这个时,它不起作用:
<flow name="ApplicationEndpoint">
<inbound-endpoint address="server:port/JSONAPI/"/>
<jersey:resources>
<component>
<spring-object bean="myJerseyService"/>
</component>
</jersey:resources>
<component>
<spring-object bean="postProcessor"/>
<component>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<flow-ref name="ErrorHandling" doc:name="Flow Reference"/>
</catch-exception-strategy>
</flow>
“postProcessor”在配置中的其他位置映射为 spring bean。
我收到的错误消息是:
org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:发现以元素“组件”开头的无效内容。需要 '{"http://www.mulesoft.org/schema/mule/core ":abstract-lifecycle-adapter-factory, "http://www.mulesoft.org/schema/mule/core ":binding}' 之一。
最佳答案
上面的错误清楚地表明标签 <component>
没有关闭..
例如,它应该采用以下格式:-
<component>
<spring-object bean="postProcessor"/>
</component>
您需要像下面这样结束标签:- </component>
还有一件事......我尝试运行你的代码,但由于 server:port/JSONAPI/
在您的 inbound-endpoint
中配置地址它给出一个错误,指出 xml 格式错误
所以我修改了您的代码如下,它运行成功:-
<flow name="ApplicationEndpoint">
<inbound-endpoint address="http://localhost:8189/JSONAPI"/>
<jersey:resources>
<component>
<spring-object bean="myJerseyService"/>
</component>
</jersey:resources>
<component>
<spring-object bean="postProcessor"/>
</component>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<flow-ref name="ErrorHandling" doc:name="Flow Reference"/>
</catch-exception-strategy>
</flow>
所以,您现在可以使用它并根据您的要求进行修改
关于java - Mule ESB - 在同一流程中配置多个组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30384697/