我正在尝试使用hibernate3-maven-plugin读取persistence.xml中的JPA实体,并创建DDL数据库脚本,以便将表插入到数据库中。下面的第一个maven插件配置可以工作并创建DDL脚本,但是pom.xml在Eclipse中查看它时有一个恼人的生命周期配置错误。我试图使用下面插件的第二种配置(带有lifecycleMappingMetadata的插件),但它没有创建DDL脚本,并且在mvn干净安装时不会抛出任何错误。有什么想法吗?
Eclipse验证错误:
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2ddl (execution: default, phase:
compile)工作,但有Eclipse验证生命周期配置错误:
<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>发布于 2014-02-05 00:52:45
应该忽略的生命周期映射是M2E的,而不是hibernate 3的。使用您的第一个块配置hibernate-maven3 3,并将此块用于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在开普勒创作。您的插入符是否与错误在一行上?)
https://stackoverflow.com/questions/18499941
复制相似问题