简体   繁体   中英

How to provide a property Bean to a Java Component in Mule Studio?

In Mule Studio 3.5, directly in the XML and in a Flow, I have the following declaration :

<component class="fr.esb.bo.GenerateReportFileComponent" doc:name="BOreport">           
            <spring:property name="boServices" ref="boServices"/>
</component>

When I launch Mule with this, I get the following error

org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'spring:property'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":abstract-interceptor, "http://www.mulesoft.org/schema/mule/core":interceptor-stack, "http://www.mulesoft.org/schema/mule/core":abstract-entry-point-resolver-set, "http://www.mulesoft.org/schema/mule/core":abstract-entry-point-resolver, "http://www.mulesoft.org/schema/mule/core":abstract-object-factory, "http://www.mulesoft.org/schema/mule/core":abstract-lifecycle-adapter-factory, "http://www.mulesoft.org/schema/mule/core":binding}' is expected.

I understand that, but how can I provide my boServices bean to my component ? With a custom-transformer, this is working well.

Define your class as a Spring bean:

<spring:beans>
  <spring:bean id="restaurantWaiter" scope="prototype" class="com.foo.RestaurantWaiter">
    <spring:property name="kitchenService">
        <spring:ref local="kitchenService"/>
    </spring:property>
  </spring:bean>
</spring:beans>

<component>
  <spring-object bean="restaurantWaiter"/>
</component>

as explained here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM