2013-08-28 33 views
0

我試圖用hibernate3-maven-plugin讀取persistence.xml中的JPA實體並創建DDL數據庫腳本,以便我可以將我的表插入我的數據庫。下面的第一個Maven插件配置工作並創建DDL腳本,但在Eclipse中查看時,pom.xml具有惱人的生命週期配置錯誤。我嘗試使用下面的插件的第二種配置(帶有lifecycleMappingMetadata的插件),但它不創建DDL腳本,並且在我執行全新安裝時不會拋出任何錯誤。有任何想法嗎?hibernate3-maven-plugin生命週期配置中未涉及的插件執行錯誤Eclipse

的Eclipse XML驗證錯誤:

Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2ddl (execution: default, phase: 
compile) 

運作,但擁有的Eclipse XML驗證生命週期配置的錯誤:

<plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>hibernate3-maven-plugin</artifactId> 
        <version>2.2</version> 
        <executions> 
         <execution> 
          <phase>compile</phase> 
          <goals> 
           <goal>hbm2ddl</goal> 
          </goals> 
         </execution> 
        </executions> 
        <configuration> 
         <components> 
          <component> 
           <name>hbm2ddl</name> 
           <implementation>jpaconfiguration</implementation> 
          </component> 
         </components> 
         <componentProperties> 
          <persistenceunit>myapi</persistenceunit> 
          <outputfilename>my.sql</outputfilename> 
          <drop>false</drop> 
          <create>true</create> 
          <export>false</export> 
          <format>true</format> 
         </componentProperties> 
        </configuration> 
       </plugin> 

lifecycleMappingMetadata不起作用:

<plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>hibernate3-maven-plugin</artifactId> 
     <version>2.2</version> 
     <configuration> 
      <lifecycleMappingMetadata> 
      <pluginExecutions> 
       <pluginExecution> 
       <pluginExecutionFilter> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>hibernate3-maven-plugin</artifactId> 
        <versionRange>[2.2,)</versionRange> 
        <phase>compile</phase> 
        <goals> 
        <goal>hbm2ddl</goal> 
        </goals> 
       </pluginExecutionFilter> 
       <action> 
        <ignore /> 
       </action> 
       </pluginExecution> 
      </pluginExecutions> 
      </lifecycleMappingMetadata> 
      <components> 
       <component> 
        <name>hbm2ddl</name> 
        <implementation>jpaconfiguration</implementation> 
       </component> 
      </components> 
      <componentProperties> 
       <persistenceunit>denaliapi</persistenceunit> 
       <outputfilename>denali.sql</outputfilename> 
       <drop>false</drop> 
       <create>true</create> 
       <export>false</export> 
       <format>true</format> 
      </componentProperties> 
     </configuration> 
     </plugin> 
+0

當這樣的錯誤發生,我通常按Ctrl + 1或右鍵單擊並添加異常到pom.xml。您也可以在eclipse設置中添加永久性異常,以免它再次發生。這是理所當然的,如果你不打擾m2e沒有意識到生命週期 – gerrytan

+0

@gerrytan - 我沒有在eclipse kepler中可用的選項 – c12

回答

0

應該忽略的生命週期映射是m2e的,而不是hibernate3的。用你的第一塊配置Hibernate-maven3,並使用此塊M2E:

<plugin> 
    <groupId>org.eclipse.m2e</groupId> 
    <artifactId>lifecycle-mapping</artifactId> 
    <version>1.0.0</version> 
    <configuration> 
    <lifecycleMappingMetadata> 
     <pluginExecutions> 
     <pluginExecution> 
      <pluginExecutionFilter> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>hibernate3-maven-plugin</artifactId> 
      <versionRange>[2.2,)</versionRange> 
      <goals> 
       <goal>hbm2ddl</goal> 
      </goals> 
      </pluginExecutionFilter> 
      <action> 
      <ignore /> 
      </action> 
     </pluginExecution> 
     </pluginExecutions> 
    </lifecycleMappingMetadata> 
    </configuration> 
</plugin> 

如果不改變之後所產生的DDL,請嘗試更改<ignore/><execute/>

(旁白: 按Ctrl + 1個暗示@gerrytan在開普勒取得的作品是您與錯誤的行插入符號?)

相關問題