作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 hibernate 4.0.0.CR4 并尝试使用 Java Persistence with Hibernate 中的“消息”示例。我能够使用 ant build 编译和运行应用程序,但是当我尝试使用 hibernatetool 导出模式时,出现错误
构建文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="HelloWorld" default="compile" basedir=".">
<property name="proj.name" value="HelloWorld"/>
<property name="proj.version" value="1.0"/>
<!-- Global properties for this build -->
<property name="src.java.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="build.dir" value="bin"/>
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
</path>
<!-- Useful shortcuts -->
<patternset id="meta.files">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</patternset>
<!-- Cleanup -->
<target name="clean">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
</target>
<!-- Compile Java source -->
<target name="compile" depends="clean">
<mkdir dir="${build.dir}"/>
<javac
srcdir="${src.java.dir}"
destdir="${build.dir}"
nowarn="on">
<classpath refid="project.classpath"/>
</javac>
</target>
<!-- Copy metadata to build classpath -->
<target name="copymetafiles">
<copy todir="${build.dir}">
<fileset dir="${src.java.dir}">
<patternset refid="meta.files"/>
</fileset>
</copy>
</target>
<!--Run HelloWorld -->
<target name="run" depends="compile, copymetafiles"
description="Build and run HelloWorld">
<java fork="true"
classname="hello.HelloWorld"
classpathref="project.classpath">
<classpath path="${build.dir}"/>
</java>
</target>
<!-- SchemaExporter -->
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.classpath"/>
<target name="schemaexport" depends="compile, copymetafiles"
description="Exports a generated schema to DB and files">
<hibernatetool destdir="${basedir}">
<classpath path="${build.dir}"/>
<configuration configurationfile="${build.dir}/hibernate.cfg.xml"/>
<hbm2ddl
drop="true"
create="true"
export="true"
outputfilename="helloworld-ddl.sql"
delimiter=";"
format="true"/>
</hibernatetool>
</target>
</project>
/home/student/workspace/HelloWorld/build.xml:61: taskdef A class needed by class org.hibernate.tool.ant.EnversHibernateToolTask cannot be found: org/hibernate/tool/ant/HibernateToolTask
最佳答案
您应该将节点设置在
<target name="schemaexport" depends="compile, copymetafiles"
description="Exports a generated schema to DB and files">
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.classpath"/>
<hibernatetool destdir="${basedir}">
<classpath path="${build.dir}"/>
<configuration configurationfile="${build.dir}/hibernate.cfg.xml"/>
<hbm2ddl
drop="true"
create="true"
export="true"
outputfilename="helloworld-ddl.sql"
delimiter=";"
format="true"/>
</hibernatetool>
</target>
关于Hibernate 4.0 hibernatetool taskdef 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7827106/
我已经创建了我的 MySQL 数据库模式,并且我正在使用 Hibernate 逆向工程文件来创建带注释的域对象 (.java)。虽然文件已正确生成,但不知何故缺少 ID 字段的“生成器”注释。 下面是
我正在使用 hibernate 4.0.0.CR4 并尝试使用 Java Persistence with Hibernate 中的“消息”示例。我能够使用 ant build 编译和运行应用程序,但
我想用 Ant 生成我的数据库模式。我正在使用 hbm2ddl 任务。 我将 Hibernate 与 JNDI 结合使用。我的 hibernate.cfg.xml 看起来像:
我是一名优秀的程序员,十分优秀!