hibernatetools自动代码构建工具
ant的build.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<project name="hibernate_tools" basedir="." default="dbschema">
<property name="src" value="src"></property>
<property name="dbschema" value="dbschema"></property>
<property name="lib" value="lib"></property>
<property name="bin" value="bin"></property>
<property name="doc" value="doc"></property>
<property name="dao" value="dao"></property>
<property name="hbmxml" value="hbmxml"></property>
<!-- path用来设定所需jar包的位置 -->
<path id="libs">
<pathelement path="${bin}"/>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef name="hibernatetools" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="libs">
</taskdef>
<target name="dbschema">
<hibernatetools>
<configuration configurationfile="${src}/hibernate.cfg.xml"/>
<hbm2ddl destdir="${dbschema}" export="false" outputfilename="dbschema.sql"/>
<hbm2java jdk5="true" destdir="${src}"/>
<hbm2doc destdir="${doc}"/>
<hbm2dao destdir="${dao}"/>
<hbm2hbmxml destdir="${hbmxml}"/>
</hibernatetools>
</target>
</project>
结合ant通过hbm文件来自动构建数据库schema和javabean等
所需要引入的jar包如下:
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
freemarker-2.3.19.jar
hibernate3.jar
hibernate-tools.jar
jtidy-r8-20060801.jar(这个是在生成hbm.xml时所需要的)
mysql-connector-java-5.1.21-bin.jar
slf4j-api-1.6.1.jar
