我在使用 Hibernate Tools 生成数据库模式时遇到了麻烦。这是我的蚂蚁文件
<project name="Schema generator for MySQL database" basedir=".">
<description>
This file is used for running Hibernate Tools Ant task.
It is used to generate database schema based on hibernate configuration
</description>
<path id="toolslib">
<path location="lib/hibernate-tools.jar" />
<path location="lib/hibernate-3.2.4.ga.jar" />
<path location="lib/freemarker.jar" />
<path location="lib/mysql-connector-java-5.1.13" />
<path location="lib/dom4j-1.6.1.jar" />
<path location="hibernate_mappings/Address.hbm.xml" />
</path>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="toolslib" />
<hibernatetool destdir="${build.dir}/generated">
<classpath>
<path location="${build.dir}/classes" />
</classpath>
<configuration configurationfile="hibernate.cfg.xml" />
<hbm2ddl />
<hbm2dao />
</hibernatetool>
</project>
运行 ant 任务时出现此错误:
C:\work\gwt_workspace\billing-cms\dao\src\main\resources\build.xml:19: org.hibernate.MappingNotFoundException: 资源: hibernate_mappings/Address.hbm.xml 未找到
我的文件系统路径层次结构是这样的:
+resources
-hibernate_mappings
-Address.hbm.xml
-User.hbm.xml
-etc..
-hibernate.cfg.xml
-build.xml
我在 hibernate.hbm.xml 中定义了我的映射,如下所示:
<mapping resource="hibernate_mappings/Address.hbm.xml" />