2011-10-19 8 views
4

私は、Hibernate 4.0.0.CR4を使用していて、HibernateでJava Persistenceから "Message"の例を試していました。私は、Antビルドを使用してapplicaitonをコンパイルして実行することができましたが、私はhibernatetool使用してスキーマをエクスポートしようとすると、私はエラーにHibernate 4.0 hibernatetool taskdefエラー

のbuild.xml

<?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 

私のクラスパス上のjar、次のとおりです ANTLR-2.7.7.jar 同級生-0.5.4.jar コモンズ・コレクション-3.2.1.jar コモンズ・ログ-1.1.1.jar dom4j-1.6.1.jar hibernate-commons-annotations-4.0.0.CR2.jar hibernate-core-4.0.0.CR4.jar hibernate-envers-4.0.0.CR4.jar hibernate-jpa -2.0-API-1.0.1.Final.jar のhsqldb.jar jandex-1.0.3.Final.jar Javassistの-3.12.1.GA.jar のJBoss-ロギング3.0.0.GA.jar のJBossいくつかのフォーラムでは、欠落しているクラスがhibernate-tools.jarの一部であることがわかりましたが、hibernate(http)のバージョンでこのjarファイルが見つかりませんでした。 ://sourceforge.net/projects/hibernate/files/hibernate4/4.0.0.CR4/)

答えて

0

のノードを
<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> 
に設定する必要があります
関連する問題