0

hibernate3-maven-plugin を使用して persistence.xml の JPA エンティティを読み取り、DDL データベース スクリプトを作成して、テーブルをデータベースに挿入できるようにしようとしています。以下の最初の maven プラグイン構成は機能し、DDL スクリプトを作成しますが、pom.xml を Eclipse で表示すると厄介なライフサイクル構成エラーが発生します。以下のプラグインの 2 番目の構成 (lifecycleMappingMetadata を使用する構成) を使用しようとしましたが、DDL スクリプトが作成されず、クリーン インストールを実行してもエラーは発生しません。何か案は?

Eclipse XML 検証エラー:

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

動作しますが、Eclipse XML Validation ライフサイクル構成エラーがあります:

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

1 に答える 1

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

(余談: @gerrytan が作成した Ctrl+1 の提案は Kepler で機能します。キャレットはエラーのある行にありますか?)

于 2014-02-05T00:52:45.847 に答える