---
title: "通过J2EE Web工程添加Flex项目，进行BlazeDS开发"
author: "whcise"
date: "2014-03-20T16:12:34Z"
tags: []
categories: ["Web前端"]
slug: "j2ee-web-flex-blazeds"
draft: false
lastmod: "2014-03-20T16:12:34Z"
id: 2034116
url: "https://whcise.iteye.com/blog/2034116"
---

环境：Eclipse 7.5 + Flex Builder 4 plugin for eclipse.

 

2\. 安装配置BlazeDS。

 

        下载blazeds.war，解压，得到目录结构：

              blazeds

             ├─META-INF

             └─WEB-INF

                  ├─classes

                  ├─flex

                  ├─lib

                  └─src 

 

        将blazeds\\WEB-INF\\lib下的所有jar文件复制到目录Sample\\WebRoot\\WEB-INF\\lib下：

           cfgatewayadapter.jar

              commons-codec-1.3.jar

              commons-httpclient-3.0.1.jar

              commons-logging.jar

              flex-messaging-common.jar

              flex-messaging-core.jar

              flex-messaging-opt.jar

              flex-messaging-proxy.jar

              flex-messaging-remoting.jar

              flex-rds-server.jar

              xalan.jar

 

 

        在WEB工程下Sample\\WebRoot\\WEB-INF目录下新建目录flex，将blazeds\\WEB-INF\\flex下的所有文件复制到新建目录下：

              messaging-config.xml

              proxy-config.xml

              remoting-config.xml

              services-config.xml

              version.properties

 

        将blazeds\\WEB-INF\\web.xml中的配置信息复制到WEB工程下的web.xml中:

 

```
<!-- Http Flex Session attribute and binding listener support -->
    <listener>
        <listener-class>flex.messaging.HttpFlexSession</listener-class>
    </listener>

    <!-- MessageBroker Servlet -->
    <servlet>
        <servlet-name>MessageBrokerServlet</servlet-name>
        <display-name>MessageBrokerServlet</display-name>
        <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
        <init-param>
            <param-name>services.configuration.file</param-name>
            <param-value>/WEB-INF/flex/services-config.xml</param-value>
       </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>MessageBrokerServlet</servlet-name>
        <url-pattern>/messagebroker/*</url-pattern>
    </servlet-mapping>
```

 

3\. 添加配置Flex项目。

　　部署Sample项目到Tomcat，启动Tomcat。下一步需要Web服务验证。

　　右键点击Sample项目，选择=》添加/更改项目类型=》添加Flex项目类型。

 

            ![](http://dl2.iteye.com/upload/attachment/0095/1376/9674750e-29c9-3e0d-85de-543b4d917194.png)

        在“使用远程对象访问服务”选项选择BlazeDS，然后Next。 

 

   
            ![](http://dl2.iteye.com/upload/attachment/0095/1378/2adf94b8-54c1-30a6-bc79-e812d4306dfe.png)  
 

        选择Web服务器webapps下的Sample目录作为根文件夹，根URL填写Web项目的Web访问路径，点击“验证配置”，若服务器正常，则验证有效，然后Finish。 

           ![](http://dl2.iteye.com/upload/attachment/0095/1380/2df1e000-1647-38ce-ba64-2597b7965798.png)

 

 4. 配置完毕，可以开始开始BlazeDS开发了。

 

 

Sujit Reddy G， 用Flash Builder 4 beta建立连接BlazeDS远程端的Flex应用程序 

[http://www.adobe.com/cn/devnet/flex/articles/flashbuilder4\_blazeds.html](http://www.adobe.com/cn/devnet/flex/articles/flashbuilder4_blazeds.html)