2014-07-05 64 views

回答

0

這個怎麼樣:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>generate-test-sql-scripts</id> 
      <phase>generate-test-sources</phase> 
      <goals> 
       <goal>run</goal> 
      </goals> 
      <configuration> 
       <tasks> 
        <property name="maven_test_classpath" refid="maven.test.classpath"/> 
        <path id="hibernate_tools_path"> 
         <pathelement path="${maven_test_classpath}"/> 
        </path> 
        <property name="hibernate_tools_classpath" refid="hibernate_tools_path"/> 
        <taskdef name="hibernatetool" 
          classname="org.hibernate.tool.ant.HibernateToolTask"/> 
        <mkdir dir="${project.build.directory}/test-classes/hsqldb"/> 
        <hibernatetool destdir="${project.build.directory}/test-classes/hsqldb"> 
         <classpath refid="hibernate_tools_path"/> 
         <jpaconfiguration persistenceunit="testPersistenceUnit" 
              propertyfile="src/test/resources/META-INF/spring/jdbc.properties"/> 
         <hbm2ddl drop="false" create="true" export="false" 
           outputfilename="create_db.sql" 
           delimiter=";" format="true"/> 
         <hbm2ddl drop="true" create="false" export="false" 
           outputfilename="drop_db.sql" 
           delimiter=";" format="true"/> 
        </hibernatetool> 
       </tasks> 
      </configuration> 
     </execution> 
    </executions> 
    <dependencies> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <version>${hibernate.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>org.slf4j</groupId> 
        <artifactId>slf4j-api</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-tools</artifactId> 
      <version>${hibernate.tools.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>org.hibernate</groupId> 
        <artifactId>hibernate-commons-annotations</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>${slf4j.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-simple</artifactId> 
      <version>${slf4j.version}</version> 
     </dependency> 
    </dependencies> 
</plugin> 
+0

我曾試圖使用ANT類似的一個,但不是與Hibernate映射類(使用說明)工作。 – dadua

+0

我有JPA和Hibernate註釋,它的工作原理。 –

相關問題