我在eclipse kepler和OpenJPA 2.2.1中遇到了同樣的問題。
該解決方案非常簡單,但有點骯髒。
首先,您需要從該網站上安裝OpenJPA的M2E連接器:
http://openjpa-maven-connector.googlecode.com/svn/trunk/openjpa-connector-update-site
接下來,您必須修改POM,並把旁邊的OpenJPA的,Maven的插件的ELEMENTO插件(build元素內),下一個定義:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>openjpa-maven-plugin</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>enhance</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
所以構建元素應該看起來像這樣(用自己的實體包):
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<verbose>true</verbose>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>mappingtool</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
com/xxxx/xxxx/*
</includes>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin definition only affects eclipse, not the mvn command execution -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>openjpa-maven-plugin</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>enhance</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
您是否找到一個好的解決方案?每次我更改一個實體時,它都不會在IDE進行的構建過程中自動增強;我必須手動調用Maven來執行此操作。 – 2014-09-23 17:41:41
@Caffé我沒有。所以我使用Ant腳本來完成這個工作,所以我可以從UI中調用它。它看起來Maven Eclipse插件仍然不滿意OpenJPA .. :( – Dreamer 2014-09-23 18:16:04