flex eclipse综合spring入门
首先下载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.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsdhttp://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,直接訪问网址是不行的。
请注明遗漏
版权声明:本文博客原创文章。博客,未经同意,不得转载。
转载于:https://www.cnblogs.com/blfshiye/p/4662428.html
flex eclipse综合spring入门相关推荐
- JAVA常用API或编程工具002---SpringSource Tool Suite:基于Eclipse的Spring应用开发环境
Spring Tool Suite(STS) 是一个基于Eclipse针对Spring应用量身定制的开发环境.提供了开发 Spring 应用必须的编码.调试.运行和部署功能.STS 在最新的 Ecli ...
- 【Spring】Spring入门
Spring 入门 Spring 全家桶 Spring Framework -- Spring 框架 , 基石 Spring Boot -- 构建项目 Spring Cloud -- 微服务 Spri ...
- Spring入门第一讲——Spring框架的快速入门
Spring的概述 什么是Spring? 我们可以从度娘上看到这样有关Spring的介绍: 说得更加详细一点,Spring是一个开源框架,Spring是于2003年兴起的一个轻量级的Java开发框架, ...
- Eclipse Che安装入门和使用(一)
Eclipse Che序列博文如下: 安装和调试篇:Eclipse Che安装入门和使用(一) Spring Web进阶篇:Eclipse Che开发Spring Web应用(入门) (二) 本文摘要 ...
- 使用Eclipse开发Spring的第一个简单程序
使用Eclipse开发Spring的第一个简单程序 本篇文章将通过一个简单的入门程序向读者演示Spring框架的使用过程,具体如下: 使用Eclipse创建Web应用并导入JAR包 使用Eclipse ...
- spring入门程序
Spring入门程序 步骤 1. 创建web项目,把sprng基础包和依赖包放入lib目录中 注意"[eclipse引入jar包的方法](https://blog.csdn.net/qq_2 ...
- IDEA下——Spring入门程序
创建一个Maven的项目,我的项目结构如下: 在pom文件里写下需要导入的依赖: <?xml version="1.0" encoding="UTF-8" ...
- spring入门详细教程(五)
前言 本篇紧接着spring入门详细教程(三),建议阅读本篇前,先阅读第一篇,第二篇以及第三篇.链接如下: Spring入门详细教程(一) https://www.cnblogs.com/jichi/ ...
- Spring入门详细教程(四)
前言 本篇紧接着spring入门详细教程(三),建议阅读本篇前,先阅读第一篇,第二篇以及第三篇.链接如下: Spring入门详细教程(一) https://www.cnblogs.com/jichi/ ...
最新文章
- java的byte php_java_浅谈java的byte数组的不同写法,(由于篇幅原因阐述的不够详 - phpStudy...
- 马云:新一轮技术革命来袭,未来90%的制造业会在互联网上
- 用LIBSVM做回归和预测的步骤
- 2021春季每日一题【week4 完结】
- 【JavaSE_06】Java中的数组(array)-练习
- 中国家用中央空调行业发展动态解析及规划趋向预测报告2022-2028年版
- 驱动利器:数据驱动下的产品决策(上)
- 链路层 ---《TCP/IP协议》卷一
- oracle 数据 时间间隔,如何掌握 Oracle 中的时间间隔型数据
- 刚刚,Redis公布了5.0版本12项新特性
- POJ 1236 Network of Schools(强连通 Tarjan+缩点)
- maven工程的多环境配置方案(profile)
- Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读
- php多进程结合Linux利器split命令实现把大文件分批高效处理
- 如何在服务台提交工单?
- 山东大学高频电子线路综合实验 调幅通信机系统实验详解
- java面经大全,献给每一个努力过,在努力以及将要努力的人。goodlucky。2018-10-15开始更新
- python3.7安装pyltp出错_python安装pyltp包
- VM虚拟机安装Windows XP Service Pack 3 (x86)
- maven-repository文件
热门文章
- php嵌入html代码的三种方法
- centos6+ 将程序 注册到 service进行启动 停止 重启等:以nginx为例,添加nginx脚本
- django快捷复习手册
- web报表工具FineReport使用中遇到的常见报错及解决办法(二)
- 企业信息化必看,跨国集团采购部门的报表系统是怎样的
- angular js 使用pdf.js_胶水(框架) Stencil.js
- python初级第三库(人工智能,web解析,人机交互)
- postman压力测试_如何用Postman简单做接口自动化
- android studio查看jar包源码,Android Studio查看源代码报错
- java heap 查看_使用VisualVM查看Java Heap Dump