First download Flashbuilder_4_7_ls10_win64.exe tried several eclipse installation plug-ins were unsuccessful, including myeclipse8.5, Spring sts2.9.2, eclipse3.5, J2eeeclipse version of 4.2.0, and later made a Flashbuilder_4_ls10.exe installation can not find the plug-in installation file originally this is a separate version, must be plug-in version only, the last download Flashbuilder_4_plugin_ LS10.exe finally configured successfully, myeclipse8.5 No, spring sts is OK.
The Spring STS deployment application is different from MyEclipse and is similar to eclipse.
There are several steps to consolidating flex and Java with STS:
1: New Dynamic Web Engineering flexweb, create Web.xml
2:blazeds-turnkey-4.0.0.14931.zip decompression, copy blazed two folders Flex and Lib to Web-inf, inside is Blaze jar package and flex profile, then modify Web.xml join Blaze support
<listener> <listener-class>flex.messaging.httpflexsession</ Listener-class> </listener> <!--messagebroker Servlet--> <servlet> <servlet-name>mess Agebrokerservlet</servlet-name> <servlet-class>flex.messaging.messagebrokerservlet</ servlet-class> <init-param> <param-name>services.configuration.file</param-name> <param-v Alue>/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: Project Right key, add/Change Project type > Add Flex Type Project, first step, Application type selection Java EE, below select BlazeDS, the second root folder fill in the path of the project in Workspase add a webcontent, such as E:\ workspaces\sts\flexweb\webcontent, root URL fill http://localhost:8080/flexweb, up and down root directory/flexweb, output folder using default E:\workspaces\sts \flexweb\webcontent\flexweb-debug, click Finish
4: After the conversion is complete, the directory has some changes, the right key project >properties>flex build path, the main source folder to Flex_src, and then automatically generated src directory under the Flexweb.mxml moved to FLEX_SRC under, Even if the environment is finished
HelloWorld
Flexweb.mxml:
<?xml version= "1.0" encoding= "Utf-8"?> <s:application xmlns:fx= "http://ns.adobe.com/mxml/2009"
Library://ns.adobe.com/flex/spark "xmlns:mx=" library://ns.adobe.com/flex/mx "minwidth=" 955 "minHeight=" > <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> <!--place non-visual elements (such as services, value objects) here--> <s:remoteob Ject id= "Myflex" destination= "mytest" result= "Myflex_resulthandler (event)"/> </fx:Declarations> <s:butt On x= "209" y= "135" label= "button" click= "Button1_clickhandler (event)"/> <s:textinput x= "166" y= "Bayi" id= "Txtname"/>
; <s:labeL x= "y=" Bayi "text=" Please enter the content: "fontsize=" fontweight= "bold" fontfamily= "in the Easy Blackbody"/> </s:Application>
which
<s:remoteobject id= "Myflex" destination= "mytest" result= "Myflex_resulthandler" (event)/>
Specifies a class hello,mytest that invokes Java corresponds to the Remoting-config.xml
In the Web-info/flex directory Remoting-config.xml join
<destination id= "MyTest" >
<properties>
<source>com.hongbo.Hello</source>
</properties>
</destination>
Result corresponds to the callback function of the Java method invocation
Build a normal Java class
Package Com.hongbo;
public class Hello {public
string SayHello (string name) {
System.out.println ("------------------------------ ------");
Return "Hello to" + name;}
That's OK.
Access Path is http://localhost:8080/flexweb/flexweb-debug/flexweb.html
The first time I'm going to report 404,problems. You cannot create an HTML wrapper, right-click to recreate the template
Add Spring Support
1:web.xml Join
<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>
Create Applicationcontext.xml under 2:SRC
<?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 Join
<factories>
<factory id= "Spring" class= "com.hongbo.SpringFactory"/>
</factories>
adding Java Classes
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, Conf
Igmap 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 Factoryin StanCE = (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 () + "s
Cope= "+ 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: Modify the Remoting-config.xml
<destination id= "MyTest" >
<properties>
<factory>spring</factory>
<source >hello</source>
</properties>
</destination>
5: Modify the corresponding Java class
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;
}
}
Finally, the Flex print statement trace does not print to the console, first uninstall Flashplayer and install a debuger version of Flashplayer, download Flashplayer_ Uninstall.zip, uninstall, download Flashplayer10r12_36_winax_debug.exe, install, uninstall after installation as if Google Browser did not affect, then eclipse modify the default browser for ie,window> Preferences>general>web Browser, choose internet Explorer, and finally, after you start Tomcat, you must right-click Debug on Mxml, and open IE will print trace. Direct access to the Web site is not possible.
If there are omissions, please point out