首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Eclipse中未涉及生命周期配置错误的hibernate3-maven-plugin插件执行

Eclipse中未涉及生命周期配置错误的hibernate3-maven-plugin插件执行
EN

Stack Overflow用户
提问于 2013-08-28 23:28:10
回答 1查看 1.5K关注 0票数 0

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

Eclipse验证错误:

代码语言:javascript
复制
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2ddl (execution: default, phase: 
 compile)

工作,但有Eclipse验证生命周期配置错误:

代码语言:javascript
复制
 <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:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2014-02-05 00:52:45

应该忽略的生命周期映射是M2E的,而不是hibernate 3的。使用您的第一个块配置hibernate-maven3 3,并将此块用于m2e:

代码语言:javascript
复制
<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在开普勒创作。您的插入符是否与错误在一行上?)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18499941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档