- 复制相关jar包到lib目录下
- HibernateTools-3.2.4.GA-R200905070146-H18/plugins/org.hibernate.eclipse_3.2.4.GA-R200905070146-H18/lib/tools
hibernate-tools.jar
freemarker.jar
- HibernateTools-3.2.4.GA-R200905070146-H18/plugins/org.hibernate.eclipse_3.2.4.GA-R200905070146-H18/lib/hibernate
hibernate3.jar
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
commons-collections-2.1.1.jar
-
HibernateTools-3.2.4.GA-R200905070146-H18/plugins/org.hibernate.eclipse_3.2.4.GA-R200905070146-H18/lib/annotations
hibernate-annotations.jar
hibernate-commons-annotations.jar
ejb3-persistence.jar
-
编写ant的build.xml文件
<?xml version="1.0" encoding="UTF-8"?> <project name="AutoGen" default="make-javacode" basedir="."> <property name="proj.home" value="E:/PowerService/PSSource" /> <property name="src.dir" value="${proj.home}" /> <property name="hibernate.cfg" value="${proj.home}/hibernate.cfg.xml" /> <property name="class.dir" value="${proj.home}/webapp/WEB-INF/classes" /> <property name="gen.dir" value="${proj.home}/gen" /> <property name="lib.dir" value="${proj.home}/webapp/WEB-INF/lib" /> <path id="build-classpath"> <fileset dir="${lib.dir}"> <include name="*.jar" /> </fileset> <pathelement location="${class.dir}" /> </path> <target name="make-javacode"> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="build-classpath" /> <hibernatetool destdir="${src.dir}/smartapp"> <configuration > <fileset dir="${src.dir}/smartapp/dev/torch/smartapp/accesscontrol/guiaccess/da"> <include name="**/*.hbm.xml"/> </fileset> </configuration> <hbm2java jdk5="true"/> </hibernatetool> </target> </project>
使用ant运行build.xml文件即可生成java code
参考资料:http://docs.jboss.org/tools/3.1.0.M2/en/hibernatetools/html/ant.html