【问题标题】:hibernate3-maven-plugin Plugin execution not covered by lifecycle configuration Error in Eclipsehibernate3-maven-plugin 插件执行未包含在生命周期配置中 Eclipse 中的错误
【发布时间】:2013-08-28 23:28:10
【问题描述】:

我正在尝试使用 hibernate3-maven-plugin 读取我的 persistence.xml 中的 JPA 实体并创建 DDL 数据库脚本,以便我可以将我的表插入到我的数据库中。下面的第一个 maven 插件配置可以工作并创建 DDL 脚本,但是在 Eclipse 中查看 pom.xml 时会出现烦人的生命周期配置错误。我尝试使用下面插件的第二个配置(带有生命周期映射元数据的那个),但它不会创建 DDL 脚本,并且在我进行 mvn 全新安装时不会抛出任何错误。有什么想法吗?

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>

【问题讨论】:

  • 发生此类错误时,我通常按 Ctrl+1 或右键单击并将异常添加到 pom.xml。您还可以为 eclipse 设置添加永久例外,这样它就不会再发生了。当然,如果您不担心 m2e 无法识别生命周期
  • @gerrytan - 我在 eclipse kepler 中没有该选项

标签: java eclipse maven jpa


【解决方案1】:

应该忽略的生命周期映射是 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,请尝试将 &lt;ignore/&gt; 更改为 &lt;execute/&gt;

(旁白: @gerrytan 提出的 Ctrl+1 建议在 Kepler 中有效。您的插入符号是否与错误对应?)

【讨论】:

    猜你喜欢
    • 2013-05-04
    • 1970-01-01
    • 1970-01-01
    • 2017-10-17
    • 2012-07-11
    • 2011-10-10
    • 2020-04-19
    • 2016-10-26
    • 2013-04-03
    相关资源
    最近更新 更多