2014-01-13 83 views
0

我有了這個樸素簡單的配置文件:爲什麼我不能導入Mule配置文件?

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

<mule xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:test="http://www.mulesoft.org/schema/mule/test" version="EE-3.4.1" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.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/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd 
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd 
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.2/mule-jms.xsd 
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/3.2/mule-test.xsd"> 

    <spring:import resource="dataSources.xml"/> 

    <jdbc-ee:connector name="apiJDBCConnector" dataSource-ref="apiLogDataSource"> 
     <jdbc-ee:query key="commitAPILogEntries" value="insert into APILogEntries 
      (requestName, parameters, serviceParameters, partnerID, partnerIP, statusCode, responseLength, time) 
      values 
      (#[map-payload:REQUEST_NAME], #[map-payload:PARAMETERS], #[map-payload:SERVICE_PARAMETERS], #[map-payload:PARTNER_ID]::int, inet(#[map-payload:PARTNER_IP]), #[map-payload:STATUS_CODE]::int, #[map-payload:RESPONSE_LENGTH]::int, TIMESTAMP WITHOUT TIME ZONE 'epoch' + #[map-payload:TIMESTAMP]::bigint * INTERVAL '1 millisecond')"></jdbc-ee:query> 
    </jdbc-ee:connector> 

</mule> 

我想要做的,是在一個單獨的配置文件來定義數據源,然後在其他地方使用這些數據源。不過,我把數據源-ref元素上得到錯誤和Mule拒絕運行。

的dataSources.xml文件看起來是這樣的:

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

    <spring:bean id="apiLogDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
     <spring:property name="driverClassName" value="${jdbc.driverClassName}"/> 
     <spring:property name="url" value="${jdbc.apilog.url}"/> 
     <spring:property name="username" value="${jdbc.apilog.username}"/> 
     <spring:property name="password" value="${jdbc.apilog.password}"/> 
    </spring:bean>  

</spring:beans> 

我在做什麼錯了,因爲我不能得到這個工作?

回答

1

你單獨的配置仍然需要加以遏制,騾子根元素中,並有必需的命名空間等,爲它工作。例如:

<?xml version="1.0" encoding="UTF-8"?> 
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xsi:schemaLocation=" 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"> 
    <spring:beans> 

     <spring:bean id="apiLogDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
      <spring:property name="driverClassName" value="${jdbc.driverClassName}"/> 
      <spring:property name="url" value="${jdbc.apilog.url}"/> 
      <spring:property name="username" value="${jdbc.apilog.username}"/> 
      <spring:property name="password" value="${jdbc.apilog.password}"/> 
     </spring:bean>  

    </spring:beans> 
</mule> 

FYI:後即使這MuleStudio可能會抱怨說,它不能找到「apiLogDataSource」,但它將會運行得很好。

相關問題