果然是不能想得太好。
近斷時(shí)間在看Spring(夏昕的開(kāi)發(fā)指南),試著在Eclipse中試試,沒(méi)想不懂還就是不懂啊,第1個(gè)例子都沒(méi)整出來(lái),后來(lái)才弄明白是那個(gè)bean.xml沒(méi)寫對(duì)。往后看了幾頁(yè)才曉得,我的Eclipse3.1.1裝了MyEclipse4.0.2GA,但是那個(gè)里面的XML(for Template)中模板只有4個(gè),有WEB和Structs的,沒(méi)有Spring,于是就有了這個(gè)念頭,自己加一個(gè)模板進(jìn)去。這樣以后開(kāi)發(fā)就不用記那樣條目了。在Eclipse中新建XML文件: 已安裝了MyEclipse插件,新建中在MyEclipse分支下有個(gè)XML,點(diǎn)擊XML(from Template)利用其自帶模板新建. 現(xiàn)舉例加入Spring的bean.xml配置文件的模板. 1.打開(kāi)目錄 myeclipse\eclipse\plugins\com.genuitec.eclipse.wizards_4.0.1 其中涉及文件為:templates.properties,這是一個(gè)模板的配置文件 打開(kāi)可以見(jiàn)到: # HTML Templates xml.template.1=Templates/Xml.xml xml.template.1.label=Default XML template xml.template.2=Templates/WebXml.xml xml.template.2.label=XML template for a web.xml file xml.template.3=Templates/WebXmlStruts.xml xml.template.3.label=XML template for a web.xml file with Struts xml.template.4=Templates/StrutsConfig.xml xml.template.4.label=XML template for a struts-config.xml file 這樣(39-47行).這既為在Eclipse中向?qū)е谐霈F(xiàn)的項(xiàng)目 2.現(xiàn)在手工進(jìn)行更改配置文件 在其中加入: xml.template.5=Templates/Spring.xml xml.template.5.label=XML template for a Spring file 意為添加一項(xiàng),模板文件是templates目錄下的spring.xml文件 3.加入模板文件 在/Templates目錄下新建一個(gè)"Spring.xml"文件: #---------------------------------------------# # <aw:description>Template for a WebXml file for Spring</aw:description> # <aw:version>1.0</aw:version> # <aw:date>02/22/2006</aw:date> # <aw:author>Tw DDM</aw:author> #---------------------------------------------# <?xml version="1.0" encoding="<aw:encoding/>"?> <!DOCTYPE web-app PUBLIC "-//SPRING//DTD BEAN//EN" " <beans> <description>This a description</description> <bean id="TheAction" class="net.ddm.MyAction" singleton="true" init-method="init" destory-method="close" depends-on="ActionManager" > <property name="message"> <value>HeLLo</value> </property> <property name="desc"> <null/> </property> <property name="dataSource"> <ref local="dataSource"/> </property> </bean> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" > <property name="jndiName"> <value>java:comp/env/jdbc/sample</value> </property> </bean>
</beans> 4.完成.重入Eclipse即可見(jiàn)到效果這個(gè)XML的內(nèi)容是照書上抄的。
Powered by: BlogJava Copyright © 大大毛