本文主要是介绍Mule 的第一个例子,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
源代码在 : http://tobeno1.iteye.com/blog/408697 (mule 版本 mule-2.2)
视频讲解 : http://www.mulesource.org/display/COMMUNITY/Meet+Mule (mule版本 mule-2.1.1)
mule的版本 : mule-2.1.2 (版本问题在启动mule时,解析config文件时,会有命名空间的问题,运行时要注意)
一、首先 设置好环境变量 :
set MULE_HOME=C:\mule-2.1.2
set PATH=%PATH%;%MULE_HOME%\bin
二、其次 mule-config.xml 文件修改如下:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.1"
xmlns:file="http://www.mulesource.org/schema/mule/file/2.1"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.1 http://www.mulesource.org/schema/mule/core/2.1/mule.xsd
http://www.mulesource.org/schema/mule/stdio/2.1 http://www.mulesource.org/schema/mule/stdio/2.1/mule-stdio.xsd
http://www.mulesource.org/schema/mule/file/2.1 http://www.mulesource.org/schema/mule/file/2.1/mule-file.xsd
http://www.mulesource.org/schema/mule/vm/2.1 http://www.mulesource.org/schema/mule/vm/2.1/mule-vm.xsd">
<stdio:connector promptMessage="What is your name?" name="ConsoleConnector"/>
<file:connector name="nameinfiles" outputPattern="file2.txt" outputAppend="true"/>
<model name="demo">
<service name="hello">
<inbound>
<stdio:inbound-endpoint system="IN"/>
</inbound>
<component class="com.join.mule.SayHello"></component>
<outbound>
<pass-through-router>
<!--<stdio:outbound-endpoint system="OUT"/>-->
<file:outbound-endpoint path="./files"/>
</pass-through-router>
</outbound>
</service>
</model>
</mule>
现在例子可以直接运行。
=================================
遇到过的问题 :
A Fatal error has occurred while the server was running:
cvc-elt.1: Cannot find the declaration of element 'mule'
(org.xml.sax.SAXParseException)
还有其他的element的解析问题,这些都是由 mule 的版本 以及 命名空间的版本 冲突 造成的。
这篇关于Mule 的第一个例子的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!