我想使用ANT從Hibernate/JPA註釋類生成SQL DDL腳本。使用ANT從JPA/Hibernate註釋類創建DDL腳本
下面是我寫基於Hibernate開發文檔URL Ant腳本:使用ClassLoader AntClassLoader [http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/
<project name="yourmarketnet" default="all" basedir=".">
<target name="ddl_generation">
<!-- paths to required jars -->
<path location="web/WEB-INF/lib/hibernate-annotations.jar" />
<path location="web/WEB-INF/lib/ejb3-persistence.jar" />
<path location="web/WEB-INF/lib/hibernate-entitymanager.jar" />
<path location="web/WEB-INF/lib/javaassist.jar" />
<path location="web/WEB-INF/lib/hibernate-tools.jar"/>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask.jar">
<classpath path="${build.dir}/web/WEB-INF/lib/hibernate-tools.jar"/>
</taskdef>
<!-- output destination -->
<hibernatetool destdir="${build.dir}">
<!-- were the annotation beans files are located-->
<classpath>
<path location="${build.dir}/web/WEB-INF/classes/com/yourmarketnet/beans" />
</classpath>
<!-- list exporters here -->
<hbm2ddl
export="false"
update="false"
drop="true"
create="true"
outputfilename="myApps.ddl"
delimiter=";"
format="false"
haltonerror="true"/>
</hibernatetool>
</target>
</project>
即時得到錯誤的taskdef類org.hibernate.tool.ant.HibernateToolTask無法找到 ]
我也檢查過hibernate-tools.jar是否在路徑中,它是(C:\ Users \ naim \ Documents \ NetBeansProjects \ yourmarketnet \ build \ web \ WEB-INF \ lib \ hibernate- tools.jar)
有人可以請一步一步告訴我如何解決/調試這個問題,謝謝。
根據您的評論編輯我原來的帖子' '我檢查了路徑$ {build.dir} /web/WEB-INF/lib/hibernate-tools.jar,實際上hibernate-tools.jar存在 –
cyber101