xdoclet2透过标注生成配置文件

xdoclet2通过标注生成配置文件
xdoclet2通过标注生成配置文件


xdoclet2首页
http://xdoclet.codehaus.org/

xdoclet首页
http://xdoclet.sourceforge.net/xdoclet/index.html

1.xdoclet2生成hibernate配置文件
hibernate tag库
http://xdoclet.sourceforge.net/xdoclet/tags/hibernate-tags.html

build.xml配置文件如下:

<target name="xdoclet4hibernate"
         depends="init">
<taskdef name="xdoclet2"
          classname="org.xdoclet.ant.XDocletTask"
          classpathref="build.classpath" />
<property name="hibernate.merge.home"
           value="${main.merge.home}/hibernate3" />
<property name="hibernate.output.home" value="${main.resources.home}" />
<delete>
   <fileset dir="${hibernate.output.home}" includes="**/*.hbm.xml" />
</delete>
<xdoclet2>
   <fileset dir="${main.java.home}">
    <include name="**/model/**/*.java" />
    <include name="**/domain/**/*.java" />
   </fileset>
   <component classname="org.xdoclet.plugin.hibernate.HibernateConfigPlugin"
              version="3.0"
              destdir="${hibernate.output.home}" />
   <component classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin"
              version="3.0"
              destdir="${hibernate.output.home}" />
</xdoclet2>
</target>

2.xdoclet2生成spring配置文件
spring tag库
http://xdoclet.sourceforge.net/xdoclet/tags/spring-tags.html

build.xml配置文件如下:
<target name="xdoclet4spring"
        depends="init"
        if="xdoclet4spring.enabled">
<taskdef name="springdoclet"
          classname="xdoclet.modules.spring.SpringDocletTask"
          classpathref="build.classpath" />
<property name="spring.merge.home" value="${main.merge.home}/spring" />
<property name="spring.output.home" value="${main.resources.home}" />
<delete>
   <fileset dir="${spring.output.home}">
    <include name="applicationContext-cpmis.xml" />
   </fileset>
</delete>
<springdoclet destDir="${spring.output.home}"
               mergeDir="${spring.merge.home}">
   <fileset dir="${main.java.home}"
           includes="com/enrising/cpmis/**/*.java" />
   <fileset dir="${main.java.home}" includes="jorsoft/**/*.java" />
   <springxml destDir="${spring.output.home}"
             destinationFile="applicationContext-cpmis.xml" />
</springdoclet>
</target>

3.xdoclet2生成struts配置文件
struts tag库
http://xdoclet.sourceforge.net/xdoclet/tags/apache-tags.html

<target name="xdoclet4web"
         depends="init"
         if="xdoclet4web.enabled"
         description="生u25104 web.xml,struts-*.xml,ibm-*.*的u26144 射u25991 件>
   <taskdef name="webdoclet"
           classname="xdoclet.modules.web.WebDocletTask"
           classpathref="build.classpath" />

   <property name="web.merge.home" value="${main.merge.home}/web" />
   <property name="web.output.home" value="${main.webapp.home}/WEB-INF" />

   <property name="struts.merge.home" value="${main.merge.home}/struts" />
   <property name="struts.dest.home" value="${main.webapp.home}/WEB-INF" />

   <mkdir dir="${web.output.home}" />
   <mkdir dir="${struts.dest.home}" />

   <delete>
    <fileset dir="${web.output.home}"
            includes="struts-config.xml" />
   </delete>
 
   <webdoclet destdir="${web.output.home}"
             excludedtags="@version, @author, @todo, @override"
             force="true"
             verbose="true"
             mergedir="${web.merge.home}">

    <fileset dir="${main.java.home}">
     <include name="**/web/**/*.java" />
    </fileset>
    <strutsconfigxml version="${struts.version}"
                    destinationFile="struts-config.xml"
                    destDir="${struts.dest.home}"
                    mergeDir="${struts.merge.home}">
    </strutsconfigxml>
   </webdoclet>
</target>

问题一:
执行ANT任务时报错-java.lang.OutOfMemoryError: Java heap space
执行 ant xdoclet4hibernate -d 打印出调试信息
在系统上增加变量
ANT_OPTS=-Xmx1024m
问题解决

问题二:
hibernate默认过滤了@auth 等JAVA标准标签,注意这些标签要书写正确

问题三:
eclipse菜单Window -> Preferences -> Java -> Installed JREs -> Edit > Default VM Parameter
加上参数-Xmx512M

检查eclipse目录$ECLIPSE_HOME\eclipse.ini
-vmargs  
-Xms80m  
-Xmx512m
1 楼 tanjunxiaoge 2011-04-11  
spring struts 是用的xdoclet1吧?xdoclet2透过标注生成配置文件