Hibernate ant 通过hbm文件生成schema和javabean

项目根目录下建立build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="build_hibernate_tool" basedir="." default="dbschema">
<property file="build.properties" ></property>
	<target name="init">
		<path id="lib.path">
			<pathelement path="${bin}"/>
			<fileset dir="${lib}">
				<include name="**/*.jar"/>
			</fileset>
		</path>
	</target>
	
	<taskdef name="hibernateTool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="lib.path"></taskdef>
	<target name="dbschema">
		<hibernateTool>
			<configuration configurationfile="${src}/hibernate.cfg.xml" />
			<hbm2ddl destdir="${dbschema}" export="false" outputfilename="dbschema.sql"/>
			<hbm2java jdk5="true" destdir="${src}" />
		</hibernateTool>
	</target>
</project>



项目根目录下建立build.properties

src=src
dbschema=dbschema
lib=lib
bin=bin




需要的jar包有:

commons-logging-1.1.1.jar
dom4j-1.6.1.jar
freemarker.jar
hibernate-tools.jar
hibernate3.jar
jsch-0.1.44.jar
mysql-connector-java-5.1.7-bin.jar
slf4j-api-1.6.1.jar

你可能感兴趣的:(Hibernate,schema,ant,Build,include,encoding)