关于mule中Spring使用中的一个问题

在mule中连接数据库时,大家通常喜欢使用spring的数据库连接以及bean的配置,但是在使用时会出现一些问题,即bean无法找到,这些,就是需要把bean的id属性改成name属性;可能是因为mule或者spring的问题,mule3.4.1识别spring bean的name属性而不是id属性;

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc"
    xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<!--     <flow name="MuleWebServiceFlow1" doc:name="MuleWebServiceFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" address="http://127.0.0.1:8081/services/getInformation" encoding="UTF-8" mimeType="text/xml" doc:name="HTTP"/>
        <cxf:jaxws-service serviceClass="mulewebservice.GetInfo" doc:name="SOAP"/>
        <component class="mulewebservice.GetInfoImpl" doc:name="Java"/>
        <file:outbound-endpoint path="F:\Test\FileTo" outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].log" responseTimeout="10000" doc:name="File"/>
    </flow> -->
           <spring:beans>
        <spring:bean id="property-placeholder" name="property-placeholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <spring:property name="location" value="classpath:db.properties"/>
        </spring:bean>
        <spring:bean id="jdbcDataSource" name="jdbcDataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
            <spring:property name="driverName" value="${database.driver}"/>
            <spring:property name="url" value="${database.connection}"/>
        </spring:bean>
    </spring:beans>
    <jdbc-ee:connector name="jdbcConnector" dataSource-ref="jdbcDataSource" pollingFrequency="5000" transactionPerMessage="false" doc:name="Database" queryTimeout="-1" validateConnections="true"> 
        <jdbc-ee:query key="read" value="SELECT id, type, data FROM test3 WHERE type=1"></jdbc-ee:query> 
        <jdbc-ee:query key="read.ack" value="UPDATE test3 SET type=2 WHERE id=#[map-payload:id]"></jdbc-ee:query> 
    </jdbc-ee:connector>
    <file:connector name="output" outputAppend="true" outputPattern="#[function:datestamp].txt" doc:name="File"></file:connector>
    <flow name="allDbRows" doc:name="allDbRows"> 
        <jdbc-ee:inbound-endpoint queryKey="read" connector-ref="jdbcConnector" doc:name="Database"></jdbc-ee:inbound-endpoint>  
        <object-to-string-transformer doc:name="Object to String"></object-to-string-transformer>  
        <file:outbound-endpoint connector-ref="output" path="/tmp/rows" doc:name="File"></file:outbound-endpoint> 
    </flow>
</mule>

如上是网上一个人给我的xml文件,放在本地测试之后,发现是因为bean使用了id,而name为空,所以就报了错,改为或者加上name并以之识别就好了。

posted @ 2013-12-05 13:03  roilat  阅读(656)  评论(0编辑  收藏  举报