2013-12-11 35 views
0

我發現這個頁面ddl-generation和我當前的代碼看起來像:執行DDL代而安裝階段

 <plugin> 
      <!-- run "mvn clean install -Dmaven.test.skip=true -X hibernate3:hbm2ddl" to generate a schema --> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>hibernate3-maven-plugin</artifactId> 
      <version>2.2</version> 
      <configuration> 
       <components> 
        <component> 
         <name>hbm2ddl</name> 
         <implementation>jpaconfiguration</implementation> 
        </component> 
       </components> 
       <componentProperties> 
        <persistenceunit>Default</persistenceunit> 
        <outputfilename>schema.ddl</outputfilename> 
        <drop>false</drop> 
        <create>true</create> 
        <export>false</export> 
        <format>true</format> 
       </componentProperties> 
      </configuration> 
     </plugin> 

它工作正常使用命令「MVN全新安裝-Dmaven.test.skip =真 - X hibernate3:hbm2ddl「,但ddl不會由」mvn clean install「生成。 我該如何改變這一點?

謝謝!

回答

0

您需要將hbm2ddl目標的bind the execution更改爲maven lifecycle phase。您可以綁定到install階段,但在ddl生成的情況下,我建議使用generate-sources階段(如果需要,這將允許您在安裝之前在生成的工件中打包生成的ddl)。

例如添加像

<executions> 
    <execution> 
     <id>execute-hbm2ddl</id> 
     <phase>generate-sources</phase> 
     <goals> 
      <goal>hbm2ddl</goal> 
     </goals> 
     ... <!-- configuration here --> 
    </execution> 
</executions> 

得到

<plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>hibernate3-maven-plugin</artifactId> 
     <version>2.2</version> 
     <executions> 
      <execution> 
      <id>execute-hbm2ddl</id> 
      <phase>generate-sources</phase> 
      <goals> 
       <goal>hbm2ddl</goal> 
      </goals> 
      <configuration> 
       <components> 
        <component> 
         <name>hbm2ddl</name> 
         <implementation>jpaconfiguration</implementation> 
        </component> 
       </components> 
       <componentProperties> 
        <persistenceunit>Default</persistenceunit> 
        <outputfilename>schema.ddl</outputfilename> 
        <drop>false</drop> 
        <create>true</create> 
        <export>false</export> 
        <format>true</format> 
       </componentProperties> 
      </configuration> 
      </execution> 
     </executions> 
    </plugin> 
+0

它的工作原理!非常感謝你! :) – user2722077