Ant+xdoclet

      使用Ant+xdoclet结合,可以很快的生成hibernate的映射文件。

      要使用xdoclet必须导入xdoclet的jar包。具体的jar包可以到apache的官方网站下载,地址为:

http://xdoclet.sourceforge.net/xdoclet/install.html。下载的时候注意下载xdoclet-bin-1.2,因为它包含了jar包、例子程序、文档等等,是最全的。

      下面是一段主流的ant+xdoclet配置

	
	<path id="xdoclet.task.classpath"><!--定义xdoclet依赖jar包路径-->
		<fileset dir="${xdoclet.home}">
			<include name="*.jar"/>
		</fileset>
	</path>
	
	<target name="hibernateTaskDef"><!--由于ant自身不带有xdoclet任务,所以必须事先定义该任务-->
		<taskdef name="hibernatedoclet"
		  classname="xdoclet.modules.hibernate.HibernateDocletTask"
		  classpathref="xdoclet.task.classpath"
		/>
	</target>
	
	<target name="hibernateMapping" depends="archive,hibernateTaskDef"><!--定义hibernate的xdoclet任务-->
        <hibernatedoclet
            destdir="${source.home}"
            excludedtags="@version,@author,@todo,@see"
            addedtags="@xdoclet-generated at ${TODAY},@copyright The XDoclet Team,@author XDoclet,@version ${version}"
            verbose="false">	
            <fileset dir="${source.home}">
                <include name="com/estar/bean/*.java"/>
            </fileset>
            <hibernate version="2.1"/> 
        </hibernatedoclet>
	</target>

  <hibernate version="3.0"/>------Sets the hibernate version to use. Legal values are "1.1", "2.0", "2.1" and "3.0". Sets the hibernate version to use. Legal values are "1.1", "2.0", "2.1" and "3.0".

猜你喜欢

转载自littie1987.iteye.com/blog/1142631
ANT