javaflex+spring+hibernate 详细配置文档.docx

上传人:b****6 文档编号:5383217 上传时间:2022-12-15 格式:DOCX 页数:37 大小:710.46KB
下载 相关 举报
javaflex+spring+hibernate 详细配置文档.docx_第1页
第1页 / 共37页
javaflex+spring+hibernate 详细配置文档.docx_第2页
第2页 / 共37页
javaflex+spring+hibernate 详细配置文档.docx_第3页
第3页 / 共37页
javaflex+spring+hibernate 详细配置文档.docx_第4页
第4页 / 共37页
javaflex+spring+hibernate 详细配置文档.docx_第5页
第5页 / 共37页
点击查看更多>>
下载资源
资源描述

javaflex+spring+hibernate 详细配置文档.docx

《javaflex+spring+hibernate 详细配置文档.docx》由会员分享,可在线阅读,更多相关《javaflex+spring+hibernate 详细配置文档.docx(37页珍藏版)》请在冰豆网上搜索。

javaflex+spring+hibernate 详细配置文档.docx

javaflex+spring+hibernate详细配置文档

配置flex+bleazeds+spring+hibernate

准备:

我个人开发时的配置:

MYSQL:

MySQL5.0

JDK:

j2sdk-1.5.0.0

TOMCAT:

tomcat-5.0.28

ECLIPSE:

eclipse-3.2

MYECLIPSE插件:

MyEclipse-5.0

Flex:

FB3_WWEJ_Plugin.exe

BLEAZEDS:

BlazeDS

Flex3SDK,还包含blazeds.war、ds-console.war和samples.war,建议初学者使用;BinaryDistribution版只包括blazeds.war,此为最简配置;而Source则包含blazeds的Java源代码,想做二次开发就下载这个。

安装:

一:

安装mysql,jdk,tomcat,eclipse,myeclipse并正确配置环境变量。

二:

安装flex3

1.首先下载安装Eclipse3.3解压到D:

\ProgramFiles\eclipse到算安装成功了.

2.下载安装FlexBuilder3.0

1.指定FlexBuilder3.0安装路径为D:

\ProgramFiles\eclipse\FlexBuilder,进下一步.(你也可设为其它目录,但不要这样:

D:

\ProgramFiles\eclipse)

2.指定Eclipse安装路径为D:

\ProgramFiles\eclipse进下一步.

3.选择是否安装浏览器FlashPlyer9插件(可选安装)

安装要花一点时间.大家慢慢等待...出现一些提示你不用管它.

等安装完后运行Eclipse.exe你是看不到Flex的..往下看我会帮你解决这个问题^_^

3.绿化FlexBuilder这是重点.

1.把D:

\ProgramFiles\eclipse\FlexBuilder\com.adobe.flexbuilder.update.site\下的plugins、features、site.xml

复制到D:

\ProgramFiles\eclipse\(如果你的eclipse目录已经有一个site.xml你只要把两个文件的feature节内容合并就好了.)

2.把D:

\ProgramFiles\eclipse\FlexBuilder\eclipse\下的plugins、features(如果有的话,这是Eclipse的一些更新)

复制到D:

\ProgramFiles\eclipse\

3.把D:

\ProgramFiles\eclipse\FlexBuilder\sdks复制到D:

\ProgramFiles\eclipse\

OK,FlexBuilder安装完成,接下来就是启动Elipse

我们现在已经可以找到Flex了.但还没完,请往下看.

4.进行Flex的配置.

在Eclipse中.点击->Window->Preferences->Flex->InstalledFlexSDKs

修改FlexSDKs2.0和FlexSDKs3.0的路径点Apply让设置成效.

重启Eclipse..你就可以开发Flex了.

5.现在你的Flex已经开始工作了.但之前安装的FlexBuilder怎么办呢.哈哈.

运行这个D:

\ProgramFiles\eclipse\FlexBuilder\UninstallAdobeFlexBuilder3Plug-in\UninstallAdobeFlexBuilder3Plug-in.exe就可以了.

三:

bleazeds

解压到任何一个地方就可以,主要用到里面的flex文件夹和lib文件夹

HELLOWORLD示例:

1.建立数据表

CREATETABLE`user`(

`UserID`int(11)NOTNULLauto_increment,

`UserName`varchar(20)defaultNULL,

`Password`varchar(20)defaultNULL,

`Email`varchar(20)defaultNULL,

PRIMARYKEY(`UserID`)

)ENGINE=InnoDBDEFAULTCHARSET=gb2312;

2.插入测试数据

3.搭配flex+bleazeds的web项目

1.新建web项目MyFirstFSH

按NEXT进入下一步

点击FINISH

2.添加bleazeds支持

1.找到已解压的bleazeds文件夹,进入到:

blazeds\WEB-INF

复制flex和lib两个文件夹到MyFirstFSH下的webRoot/WEB-INF目录下

2.在web.xml文件中添加代码:

--HttpFlexSessionattributeandbindinglistenersupport-->

flex.messaging.HttpFlexSession

--MessageBrokerServlet-->

MessageBrokerServlet

flex.messaging.MessageBrokerServlet

services.configuration.file

/WEB-INF/flex/services-config.xml

1

MessageBrokerServlet

/messagebroker/*

将web工程添加到tomcat中

3.添加flex工程

1.右键MyFirtstFSH,选择:

FlexProjectNature-AddFlexProjectNature

注:

选择J2EE,作用LCDS远程对象

Rootfolder:

选择刚才Deploy的工程路径

RootURL:

TOMCAT服务器的启动路径

Contextroot:

编译后的FLEX文件保存路径

Outputfolder:

工程重构后FLEX文件的输出路径

[点击Finish完成]

2配置Flex项目属性

在Flex视图下,右键properties打开项目属性设置对话框.选择“FlexBuildPath”,出现以下对话框:

Outputfolder:

工程FLEX文件的输出路径

OutputfolderURL:

工程在TOMCAT服务器的启动路径

――――――――――――――――――――――――――

选择“FlexCompiler”,出现以下对话框:

选择你当前用的FLEXSDK(如何你前面步骤配置好的话就不会出错了!

[点击Apply应用]

―――――――――――――――――――――――――――――――――――

选择“FlexServer”,出现以下对话框:

Contextroot:

是你的工程的根目录

[点击OK完成设置]

这时会出现错误提示:

右键“错误”信息,Recreate…

3.到了这个时候基本上已经搭建好flex+bleazeds的web环境,现在来测试一下。

新建一个包:

com.wingo.myfirstfsh.web.ro

在包中新一个类:

HelloWorld,作用flex的一个远程对象

packagecom.wingo.myfirst.web.ro;

publicclassHelloWorld{

publicStringsayHelloTo(Stringname){

return"Hello"+name;

}

}

在WEB-INF/flex/remotiong-config.xml中注册这个远程对象

com.wingo.myfirstfsh.web.ro.HelloWorld

编辑FLEX应用程序

在src/MyFirstFSH.mxml中添加以下代码:

xmlversion="1.0"encoding="utf-8"?

>

Applicationxmlns:

mx="layout="absolute">

RemoteObjectid="say"destination="Hello">

RemoteObject>

Buttonx="335"y="80"label="Click"click="remotingSayHello(event);"/>

TextInputx="159"y="80"id="tiName"/>

Labelx="109"y="82"text="name:

"/>

Labeltext="{say.sayHelloTo.lastResult}"x="44"y="162"width="448"height="71"id="lblView"color="#FCEE09"fontSize="20"fontWeight="bold"textDecoration="underline"fontStyle="normal"/>

Script>

[CDATA[

functionremotingSayHello(event:

Event):

void{

variname:

String=tiName.text;

say.sayHelloTo(iname);

}

]]>

Script>

Application>

启动tomcat打开http:

//localhost:

8080/MyFirstFSH/pages/MyFirstFSH.html

到了这一步,flex+bleazeds已经完成

4.加上spring

1.右键Myeclipse-Addspring

2.添加包:

mon

3.添加SpringFactory.java(网上的)

packagemon;

importorg.springframework.context.ApplicationContext;

importorg.springframework.web.context.support.WebApplicationContextUtils;

importorg.springframework.beans.BeansException;

importorg.springframework.beans.factory.NoSuchBeanDefinitionException;

importflex.messaging.FactoryInstance;

importflex.messaging.FlexFactory;

importflex.messaging.config.ConfigMap;

importflex.messaging.services.ServiceException;

/**

*Thisinterfaceisimplementedbyfactorycomponentswhichprovide

*instancestotheflexmessagingframework.Toconfigureflexdataservices

*tousethisfactory,addthefollowinglinestoyourservices-config.xml

*file(locatedintheWEB-INF/flexdirectoryofyourwebapplication).

*

*<factories>

*<factoryid="spring"class="flex.samples.factories.SpringFactory"/>

*</factories>

*

*Youalsomustconfigurethewebapplicationtousespringandmustcopythespring.jar

*fileintoyourWEB-INF/libdirectory.Toconfigureyourappservertousespring,

*youaddthefollowinglinestoyourWEB-INF/web.xmlfile:

*

*<context-param>

*<param-name>contextConfigLocation</param-name>

*<param-value>/WEB-INF/applicationContext.xml</param-value>

*</context-param>

*

*<listener>

*<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

*</listener>

*

*ThenyouputyourspringbeanconfigurationinWEB-INF/applicationContext.xml(asperthe

*lineabove).Forexample:

*

*<?

xmlversion="1.0"encoding="UTF-8"?

>

*<!

DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//EN""http:

//www.springframework.org/dtd/spring-beans.dtd">

*

*<beans>

*<beanname="weatherBean"class="dev.weather.WeatherService"singleton="true"/>

*</beans>

*

*Nowyouarereadytodefineadestinationinflexthatmapstothisexistingservice.

*Todothisyou'daddthistoyourWEB-INF/flex/remoting-config.xml:

*

*<destinationid="WeatherService">

*<properties>

*<factory>spring</factory>

*<source>weatherBean</source>

*</properties>

*</destination>

*

*@authorJeffVroom

*/

publicclassSpringFactoryimplementsFlexFactory

{

privatestaticfinalStringSOURCE="source";

/**

*Thismethodcanbeusedtoinitializethefactoryitself.Itiscalledwithconfiguration

*parametersfromthefactorytagwhichdefinestheidofthefactory.

*/

publicvoidinitialize(Stringid,ConfigMapconfigMap){}

/**

*Thismethodiscalledwhenweinitializethedefinitionofaninstance

*whichwillbelookedupbythisfactory.Itshouldvalidatethat

*thepropertiessuppliedarevalidtodefineaninstance.

*Anyvalidpropertiesusedforthisconfigurationmustbeaccessedto

*avoidwarningsaboutunusedconfigurationelements.Ifyourfactory

*isonlyusedforapplicationscopedcomponents,thismethodcansimply

*returnafactoryinstancewhichdelegatesthecreationofthecomponent

*totheFactoryInstance'slookupmethod.

*/

publicFactoryInstancecreateFactoryInstance(Stringid,ConfigMapproperties)

{

SpringFactoryInstanceinstance=newSpringFactoryInstance(this,id,properties);

instance.setSource(properties.getPropertyAsString(SOURCE,instance.getId()));

returninstance;

}//endmethodcreateFactoryInstance()

/**

*Returnstheinstancespecifiedbythesource

*andpropertiesarguments.Forthefactory,thismaymean

*constructinganewinstance,optionallyregisteringitinsomeother

*namespacesuchasthesessionorJNDI,andthenreturningit

*oritmaymeancreatinganewinstanceandreturningit.

*Thismethodiscalledforeachrequesttooperateonthe

*givenitembythesystemsoitshouldberelativelyefficient.

*

*Ifyourfactorydoesnotsupportthescopeproperty,it

*reportanerrorifscopeissuppliedintheproperties

*forthisinstance.

*/

publicObjectlookup(FactoryInstanceinst)

{

SpringFactoryInstancefactoryInstance=(SpringFactoryInstance)inst;

returnfactoryInstance.lookup();

}

 

staticclassSpringFactoryInstanceextendsFactoryInstance

{

SpringFactoryInstance(SpringFactoryfactory,Stringid,ConfigMapproperties)

{

super(factory,id,properties);

}

 

publicStringtoString()

{

return"SpringFactoryinstanceforid="+getId()+"source="+getSource()+"scope="+getScope();

}

publicObjectlookup()

{

ApplicationContextappContext=WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());

StringbeanName=getSource();

try

{

returnappContext.getBean(beanName);

}

catch(NoSuchBeanDe

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1