【发布时间】:2015-06-20 12:13:33
【问题描述】:
如果我直接执行 mvn 目标 mvn hibernate3:hbm2java,我有以下 pom.xml。我现在想在generate-entity 阶段让它成为执行的一部分。我在插件中包含了一些依赖项。
这是工作的 pom。
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>jdbcconfiguration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<revengfile>src/main/resources/reveng.xml</revengfile>
<propertyfile>src/main/resources/hibernate.properties</propertyfile>
<packagename>com.whatever.domain</packagename>
<jdk7>true</jdk7>
<ejb3>true</ejb3>
</componentProperties>
</configuration>
<dependencies>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.22</version>
</dependency>
</dependencies>
</plugin>
</plugins>
当我执行 mvn hibernate3:hbm2java 时,这会按预期工作。
但我在 pom.xml 中包含了执行部分。现在 Eclipse 用这个错误消息提示我
cvc-complex-type.2.4.a: Invalid content was found starting with element 'dependencies'. One of '{"http://
maven.apache.org/POM/4.0.0":inherited}' is expected.
这是修改后的 pom.xml,在 dependencies block 内部插件附近存在问题
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>generate-entity</id>
<phase>generate-entity</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2hbmxml</name>
<implementation>jdbcconfiguration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
<component>
<name>hbm2java</name>
<implementation>jdbcconfiguration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<revengfile>src/main/resources/reveng.xml</revengfile>
<propertyfile>src/main/resources/hibernate.properties</propertyfile>
<packagename>com.whatever.domain</packagename>
<jdk7>true</jdk7>
<ejb3>true</ejb3>
</componentProperties>
</configuration>
<dependencies> --- Eclipse shows errors here
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.22</version>
</dependency>
</dependencies>
</execution>
</executions>
</plugin>
</plugins>
【问题讨论】:
标签: hibernate maven maven-3 maven-plugin