开始Mule之行

开始Mule之行

2072人阅读 评论(1) 收藏 举报

 

Hello, Mule!

这页描述快速下载、安装和运行Mule ESB。接下来,你将要配置你的开发环境,启动Mule ESB 3,并成功地部署你的第一个Mule ESB应用。

完整的安装过程,包括如何设置额外的工具如Maven,控制在Mule启动时如何配置见 Complete Installation Manual.

前提

·       JDK.6.0及以上

下载和安装Mule

1.     在你的浏览器中,进入 Mule download page下载Mule

2.     如果是windows请下载.zip,如果是Linux/UNIX请下载the .tar.gz。在Linux/UNIX,你还可以使用wget 如下。

3.        wget http://dist.codehaus.org/mule/distributions/mule-standalone-3.2.0.tar.gz.

4.     解压文件 

安装Mule的路径不有空格

5.     Linux/UNIX,可以使用以下命令: tar -xvzf mule-standalone-3.2.0.tar.gz

如何你是从Mule ESB 2.2升级,先前的Mule ESB版本需要设置一个环境变量MULE_HOME 运行Mule。而对于Mule 3.1,这个MULE_HOME不再需要了。在运行Mule3.2时,请确认该变量已移除。

安装Eclipse和Mule IDE

在开始一个Mule应用之间,请安装Mule IDE。

1.     如果你没有安装Eclipse version 3.4或更高的,从这里 http://www.eclipse.org/downloads/ 下载最新版本并安装。MuleSoft推荐Eclipse Java EE开发包。但你也能安装Java开发包

2.     启动Eclipse,并为Mule的安装设置工装空间(重要: 确保你的工作空间路径目录或mule应用运行的目录不含空格)

Eclipse 3.5/3.6/3.7 (Galileo/Helios/Indigo) 按以下步骤安装Mule IDE:

1.     进入eclipse,点击菜单Help > Install New Software.

2.     点击Add 按钮,弹出的的对话框,在Location中输入 http://dist.muleforge.org/mule-ide/updates-2.1.x/ 后按Enter。Mule IDE就会出现在可用软件列表里。

3.     选中Mule IDE后点击Next. Eclipse将会运行一会,完成后点击Next

4.     浏览Mule IDE license, 选择accept the license, 然后点击Finish。

5.     点击Yes重启Eclipse.

Eclipse version 3.4 (Ganymede)

1.     进入eclipse,Help > Software Updates.

2.     在可用软件条里,点击Add Site.

3.     在location输入 http://dist.muleforge.org/mule-ide/updates-2.1.x/ 后点OK.。它会出现在可用软件列表里。

4.     扩展这个列表,找到Mule IDE。选择Mule IDE并点击Install.

5.     点击Next, 阅读并接受license agreement terms, 然后点击Finish.

6.     选择后台安装 

7.     完成后重启Eclipse。.

配置Mule Distribution

为了正确运行Mule,你必须在你的Mule distribution的location中说明

 

1.     选择 Window > Preferences. (On Mac OS X, chooseEclipse > Preferences.)

2.     选择Mule, 然后点击Add.  

3.     注明你的Mule主目录。然后点OK。

4.     选择Mule distribution's复选框, 点击Apply,  然后点OK.

创建一个Mule应用

1.     File > New > Project, 扩展Mule文件夹并选择 Mule Project, 然后点Next.

2.     输入项目名,不能有空格, 如果你不想把你的项目放到默认工作空间。反选Use default location输入你自己的路径。

3.     点击Finish,Mule IDE将产生你的项目。在Package Explorer面板里就会有你的项目。

4.     创建conf目录

5.     在conf目录中创建一个"mule-config.xml."的文件。

6.      在mule-config.xml中添加下列配置信息:

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

 

<mule xmlns="http://www.mulesoft.org/schema/mule/core"

      xmlns:script="http://www.mulesoft.org/schema/mule/scripting"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="

      http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd

      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd" >

 

    <simple-service name="hello" address="http://localhost:8080/hello">

        <script:component>

            <script:script engine="groovy">

                <script:text>return "Hello World"</script:text>

            </script:script>

        </script:component>

    </simple-service>

</mule>


注意,你刚刚做的是创建了一个Mule基于XML驱动应用。当你创建了一个配置,你就创建了一个mule应用。

运行这个应用

1.     在Package Explorer, 扩展conf目录,并右击 mule-config.xml配置文件

2.     点击Run As > Mule Server.

 

一个新的运行配置自动创建了。而且服务也开始了。为了触发这个Hello服务,在浏览器中输入 http://localhost:8080/hello 。响应如图所示出现文本"Hello World."

成功了。你已经初步完成了Mule开发环境设置,并创建和运行了你的第一个应用。

下一步

·       Run the example launcher  for the included examples to learn more about how to program Mule.

·       You can now modify the configuration file, or create a new configuration file as described in theMule IDE User Guide.

·       If you want to use Maven for a task such as using the Maven archetypes for creating transports and modules, seeSetting Up Eclipse for Use with Maven for complete instructions.

转:http://blog.csdn.net/iamstudyingjava/article/details/6987551

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值