首先下载FlashBuilder_4_7_LS10_win64.exe试了几eclipse安装没有成功插头,含有myeclipse8.5、spring sts2.9.2、eclipse3.5、j2eeeclipse版本号4.2.0,后来搞了一个FlashBuilder_4_LS10.exe安装完找不到插件安装文件原来这个是单独版,必须插件版才行,最后下载FlashBuilder_4_Plugin_LS10.exe最终配置成功了。myeclipse8.5不行,spring
sts能够了。

spring sts部署应用跟myeclipse不一样,比較类似eclipse。

用sts整合flex和java有几个步骤:

1:新建动态webprojectflexweb,创建web.xml

2:blazeds-turnkey-4.0.0.14931.zip解压,复制blazed两个目录flex和lib到WEB-INF下。里面是blaze的jar包和flex配置文件,然后改动web.xml增加blaze支持

<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener> <!-- MessageBroker Servlet -->
<servlet>
<servlet-name>MessageBrokerServlet</servlet-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类型项目,第一步,应用程序类型选择J2EE。下方选择BlazeDS。第二部根目录填入项目在workspase的路径加一个WebContent。如E:\workspaces\sts\flexweb\WebContent,根URL填http://localhost:8080/flexweb。上下文根目录/flexweb,输出目录使用默认E:\workspaces\sts\flexweb\WebContent\flexweb-debug,点击finish

4:转换完毕后,文件夹有些变化,右键项目>properties>flex构建路径,主源文件夹改为flex_src,然后把自己主动生成的src文件夹下的flexweb.mxml移动到flex_src下,环境搭建就算完毕了

HelloWorld

flexweb.mxml:

<?

xml version="1.0" encoding="utf-8"?

>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent; protected function myFlex_resultHandler(event:ResultEvent):void{
var name:String=event.result as String;
Alert.show(name);
}
protected function button1_clickHandler(event:MouseEvent):void
{
myFlex.sayHello(txtName.text);
}
]]>
</fx:Script> <fx:Declarations>
<!-- 将非可视元素(比如服务、值对象)放在此处 -->
<s:RemoteObject id="myFlex" destination="mytest" result="myFlex_resultHandler(event)"/>
</fx:Declarations>
<s:Button x="209" y="135" label="按钮" click="button1_clickHandler(event)"/>
<s:TextInput x="166" y="81" id="txtName"/>
<s:Label x="10" y="81" text="请输入内容:" fontSize="15" fontWeight="bold" fontFamily="中易黑体"/>
</s:Application>

当中

<s:RemoteObject id="myFlex" destination="mytest" result="myFlex_resultHandler(event)"/>

指定了一个调用Java的类Hello,mytest相应到remoting-config.xml

在WEB-INFO/flex文件夹下remoting-config.xml增加

<destination id="mytest">
<properties>
<source>com.hongbo.Hello</source>
</properties>
</destination>

result相应的是java方法调用的回调函数

建一个普通java类

package com.hongbo;

public class Hello {

	public String sayHello(String name){
System.out.println("------------------------------------");
return "Hello First Demo " + name;
}
}

这样就OK了

訪问路径是http://localhost:8080/flexweb/flexweb-debug/flexweb.html

第一次会报404,problems提示无法创建html包装器,右键点击又一次创建模板

加入Spring支持

1:web.xml增加

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml </param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

2:src下创建applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <bean id="hello" class="com.hongbo.Hello">
<property name="testSpring">
<ref bean="testSpring"/>
</property>
</bean>
<bean id="testSpring" class="com.hongbo.test.impl.TestSpringImpl"/>
</beans>

3:WEB-INF/flex/service-config.xml增加

<factories>
<factory id="spring" class="com.hongbo.SpringFactory" />
</factories>

加入java类

package com.hongbo;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import flex.messaging.FactoryInstance;
import flex.messaging.FlexFactory;
import flex.messaging.config.ConfigMap;
import flex.messaging.services.ServiceException;
public class SpringFactory implements FlexFactory {
private static final String SOURCE = "source"; public void initialize(String id, ConfigMap configMap) {
} public FactoryInstance createFactoryInstance(String id, ConfigMap properties) {
SpringFactoryInstance instance = new SpringFactoryInstance(this, id,
properties);
instance.setSource(properties.getPropertyAsString(SOURCE, instance
.getId()));
return instance;
} // end method createFactoryInstance() public Object lookup(FactoryInstance inst) {
SpringFactoryInstance factoryInstance = (SpringFactoryInstance) inst;
return factoryInstance.lookup();
} static class SpringFactoryInstance extends FactoryInstance {
SpringFactoryInstance(SpringFactory factory, String id,
ConfigMap properties) {
super(factory, id, properties);
} public String toString() {
return "SpringFactory instance for id=" + getId() + " source="
+ getSource() + " scope=" + getScope();
} public Object lookup() {
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());
String beanName = getSource(); try {
return appContext.getBean(beanName);
} catch (NoSuchBeanDefinitionException nexc) {
ServiceException e = new ServiceException();
String msg = "Spring service named '" + beanName
+ "' does not exist.";
e.setMessage(msg);
e.setRootCause(nexc);
e.setDetails(msg);
e.setCode("Server.Processing");
throw e;
} catch (BeansException bexc) {
ServiceException e = new ServiceException();
String msg = "Unable to create Spring service named '"
+ beanName + "' ";
e.setMessage(msg);
e.setRootCause(bexc);
e.setDetails(msg);
e.setCode("Server.Processing");
throw e;
}
} } }

4:改动remoting-config.xml

<destination id="mytest">
<properties>
<factory>spring</factory>
<source>hello</source>
</properties>
</destination>

5:改动对应的Java类

package com.hongbo;

import com.hongbo.test.TestSpring;

public class Hello {

	private TestSpring testSpring;

	public void setTestSpring(TestSpring testSpring) {
this.testSpring = testSpring;
} public String sayHello(String name){
return testSpring.testSpring(name);
}
}
package com.hongbo.test;

public interface TestSpring {

	String testSpring(String name);
}
package com.hongbo.test.impl;

import com.hongbo.test.TestSpring;

public class TestSpringImpl implements TestSpring{

	public String testSpring(String name){
System.out.println("test spring-------------------------------------"+name);
return "test spring "+name;
}
}

最后,flex打印语句trace不会打印到控制台,要先卸载flashplayer再安装一个debuger版的flashplayer,下载flashplayer_uninstall.zip,卸载,下载flashplayer10r12_36_winax_debug.exe。安装,卸载安装后好像谷歌浏览器没影响,然后eclipse改动默认浏览器为IE,window>preferences>General>Web browser。选择Internet Explorer,最后还有,启动tomcat后。必须在mxml上面右键debug执行,打开的IE才会打印trace,直接訪问网址是不行的。

请注明遗漏

版权声明:本文博客原创文章。博客,未经同意,不得转载。

flex eclipse综合spring入门的更多相关文章

  1. Spring入门学习(一)

    SpringMVC基础平台补充(2016.03.03) 如果想要开发SpringMVC,那么前期依次安装好:JDK(jdk-8u74-windows-x64,安装后配置环境变量JAVA_HOME和CL ...

  2. spring 入门篇

    spring 入门篇         相对于Hibernate(冬眠),Spring(春天),具有更多的诗意与希望的感觉,是为了解决传统J2EE开发效率过低.开发商之间不统一.没有真正实现“写一次到处 ...

  3. Spring 入门 web.xml配置详解

    Spring 入门 web.xml配置详解 https://www.cnblogs.com/cczz_11/p/4363314.html https://blog.csdn.net/hellolove ...

  4. Spring入门1. IoC入门实例

    Spring入门1. IoC入门实例 Reference:Java EE轻量级解决方案——S2SH 前言: 之前学习过关于Spring的一点知识,曾经因为配置出现问题,而总是被迫放弃学习这些框架技术, ...

  5. SSM(spring mvc+spring+mybatis)学习路径——1-1、spring入门篇

    目录 1-1 Spring入门篇 专题一.IOC 接口及面向接口编程 什么是IOC Spring的Bean配置 Bean的初始化 Spring的常用注入方式 专题二.Bean Bean配置项 Bean ...

  6. Eclipse Che安装入门和使用(一)

    Eclipse Che序列博文如下: 安装和调试篇:Eclipse Che安装入门和使用(一) Web进阶篇:Eclipse Che开发Spring Web应用(入门) (二) 本文摘要: Eclip ...

  7. IDEA一步步创建Maven管理的Spring入门程序

    目前,做Java开发的很多人都在使用IDEA了,而有些人也选择用Eclipse,我这里介绍一下IDEA一步步创建Maven项目的步骤,并创建一个Spring的入门程序(Java项目,非Web项目),讲 ...

  8. 【Spring Framework】Spring入门教程(三)使用注解配置

    本文主要介绍四个方面: (1) 注解版本IOC和DI (2) Spring纯注解 (3) Spring测试 (4) SpringJDBC - Spring对数据库的操作 使用注解配置Spring入门 ...

  9. Spring入门(10)-Spring JDBC

    Spring入门(10)-Spring JDBC 0. 目录 JdbcTemplate介绍 JdbcTemplate常见方法 代码示例 参考资料 1. JdbcTemplate介绍 JdbcTempl ...

随机推荐

  1. hdu 4771 Stealing Harry Potter&#39;s Precious

    题目:给出一个二维图,以及一个起点,m个中间点,求出从起点出发,到达每一个中间的最小步数. 思路:由于图的大小最大是100*100,所以要使用bfs求出当中每两个点之间的最小距离.然后依据这些步数,建 ...

  2. [WPF]入门理解Binding 数据驱动思想

    站在一个WinForm程序员的角度去考虑,他会做这样几件事情: 响应slider1的ValueChanged事件,在事件处理函数中让textBox1显示slider1的Value 响应textBox1 ...

  3. windows phone 加速计(5)

    原文:windows phone 加速计(5) 在windows phone 中存在着加速计,我们可以利用加速计获得用户手机的状态,根据手机状态调整我们的程序,这样会更人性化:windows phon ...

  4. Windows Phone开发(19):三维透视效果

    原文:Windows Phone开发(19):三维透视效果 三维效果也可以叫透视效果,所以,我干脆叫三维透视效果.理论知识少讲,直接用例开场吧,因为这个三维效果其实很简单,比上一节中的变换更省事,不信 ...

  5. elasticsearch中国字(mmseg)——手动添加字典

    elasticsearch中国文字本身并不是一个理想的插件效果.手动添加字典可以补偿在一定程度上. 后发现了几个实验,mmseg分段机制采用正向最长匹配算法.例如,抵抗"小时报"这 ...

  6. 2014在辛星Javascript口译科

    ***************概要*************** 1.Javascript是一种原型化继承的基于对象的动态类型的脚本语言,它区分大写和小写.主要执行在client,用户即使响应用户的操 ...

  7. 左右PHP自增力、神秘递减操作

    首先看一个面试题: $a = 1; $b = &$a; if ($b == $a++) echo "true"; else echo "false"; ...

  8. 单选框和下拉框的jquery操作

    单选框 <input type="radio" name="rdSendType" value="email" checked=&qu ...

  9. BP神经网络的基本原理

    2.1 BP神经网络基本原理 BP网络模型处理信息的基本原理是:输入信号Xi通过中间节点(隐层点)作用于输出节点.经过非线形变换,产生输出信号Yk,网络训练的每一个样本包含输入向量X和期望输出量t,网 ...

  10. ServiceStack.Hello——跨平台.net REST api服务搭建

    ServiceStack.Hello--跨平台.net REST api服务搭建 自己创建: https://github.com/ServiceStack/ServiceStack/wiki/Cre ...