大大毛 的笔记

  DDM's Note

哪怕没有办法一定有说法,
就算没有鸽子一定有乌鸦,
固执无罪 梦想有价,
让他们惊讶.

posts - 14, comments - 23, trackbacks - 0, articles - 58
   :: 首页 ::  :: 联系 ::  :: 管理

手工添加MyEclipse的XML文件模板

Posted on 2006-03-09 03:57 大大毛 阅读(4171) 评论(1)  编辑  收藏 所属分类: Spring

近断时间在看Spring(夏昕的开发指南),试着在Eclipse中试试,没想不懂还就是不懂啊,第1个例子都没整出来,后来才弄明白是那个bean.xml没写对。往后看了几页才晓得,我的Eclipse3.1.1装了MyEclipse4.0.2GA,但是那个里面的XML(for Template)中模板只有4个,有WEB和Structs的,没有Spring,于是就有了这个念头,自己加一个模板进去。这样以后开发就不用记那样条目了。

在Eclipse中新建XML文件:
 已安装了MyEclipse插件,新建中在MyEclipse分支下有个XML,点击XML(from Template)利用其自带模板新建.
 现举例加入Spring的bean.xml配置文件的模板.
 1.打开目录 myeclipse\eclipse\plugins\com.genuitec.eclipse.wizards_4.0.1
  其中涉及文件为:templates.properties,这是一个模板的配置文件
  打开可以见到:
  # 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中向导中出现的项目
 2.现在手工进行更改配置文件
  在其中加入:
  xml.template.5=Templates/Spring.xml
  xml.template.5.label=XML template for a Spring file
  意为添加一项,模板文件是templates目录下的spring.xml文件
 3.加入模板文件
  在/Templates目录下新建一个"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"
  "http://www.springframework.org/dtd/spring-beans.dtd">
  <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即可见到效果

这个XML的内容是照书上抄的。


评论

# re: 手工添加MyEclipse的XML文件模板[未登录]  回复  更多评论   

2015-05-25 19:40 by allen
请问,eclipse下面有没有呢?现在想要实现eclipse的xml的模板进行配置修改,简单说,就是把新建时候的名字作为其中的一个tag;找了很久没有找到方法

只有注册用户登录后才能发表评论。


网站导航:
 

i am ddm