Java Maven Eclipse插件和openjpa增强的问题
我们当前的项目是在STS(Eclipse)上集成Spring3/OpenJPA与Roo和maven。Java Maven Eclipse插件和openjpa增强的问题,java,eclipse,maven,openjpa,Java,Eclipse,Maven,Openjpa,我们当前的项目是在STS(Eclipse)上集成Spring3/OpenJPA与Roo和maven。M2E插件有点问题,因为它无法处理实体增强 因此,从编程的角度来看,我们不能在Eclipse下通过单击在Maven上构建整个项目,而是必须让STS(Eclipse)先构建项目,然后运行Ant脚本来增强实体,然后刷新项目,这有点笨拙,然后刷新服务器部署。不是很有效 我想这是一个暂时的问题,所以创建这个线程,看看是否有任何更新 似乎有一个工具可用(),但它似乎不支持最新的Eclipse(STS2.9.
M2E
插件有点问题,因为它无法处理实体增强
因此,从编程的角度来看,我们不能在Eclipse下通过单击在Maven上构建整个项目,而是必须让STS(Eclipse)
先构建项目,然后运行Ant
脚本来增强实体,然后刷新项目,这有点笨拙,然后刷新服务器部署
。不是很有效
我想这是一个暂时的问题,所以创建这个线程,看看是否有任何更新
似乎有一个工具可用(),但它似乎不支持最新的Eclipse(STS2.9.1基于Eclipse3.7,该工具仅涵盖3.4)
所以问题变成了:有没有任何方法(或工具)可以将所有东西(构建
,编译和增强
)集成在一起(可能只在Maven上设计POM)
很高兴听到任何建议。谢谢。@subrule
我的项目没有使用Maven,只有ANT,下面的ANT脚本有助于增强我的构建
<target name="enhance" depends="compile">
<echo message="Enhancing...."/>
<!-- ***************************************************************************************************************** -->
<!-- DO NOT DELETE FOLLOWING CODE. THIS IS ADDED FOR ENCHANCING THE CLASSES AT COMPILE TIME. IT IS REQUIRED BY OPENJPA -->
<!-- Define the classpath to include the necessary files. -->
<!-- ex. openjpa jars, persistence.xml, orm.xml, and target classes -->
<path id="jpa.enhancement.classpath">
<!-- Assuming persistence.xml/orm.xml are in META-INF -->
<pathelement location="META-INF" />
<!-- Location of the .class files -->
<pathelement location="${build.classes}" />
<!-- Add the openjpa jars -->
<fileset dir="OpenJPA_lib_jar">
<include name="*.jar" />
</fileset>
</path>
<!-- This is a bit of a hack, but I needed to copy the persistence.xml file from my src dir
to the build dir when we run enhancement -->
<!--<copy includeemptydirs="false" todir="bin">
<fileset dir="src" excludes="**/*.launch, **/*.java"/>
</copy>-->
<!-- define the openjpac task; this can be done at the top of the -->
<!-- build.xml file, so it will be available for all targets -->
<taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="jpa.enhancement.classpath" />
<!-- invoke enhancer on all .class files below the model directory -->
<openjpac>
<classpath refid="jpa.enhancement.classpath" />
<fileset dir=".">
<include name="**/model/*.class" />
</fileset>
<config propertiesFile = "${basedir}/src/META-INF/persistence.xml"/>
</openjpac>
<echo message="Enhancement complete" />
<!-- ***************************************************************************************************************** -->
</target>
希望这对您有所帮助。我在EclipseKepler和OpenJPA2.2.1上也遇到了同样的问题
解决方案很简单,但有点脏
首先,您需要从此站点安装OpenJPA m2e连接器:
接下来,您必须修改POM,并在openjpa maven插件的elemento(内部构建元素)旁边放置下一个定义:
<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>
org.eclipse.m2e
生命周期映射
1.0.0
openjpa maven插件
openjpa maven插件
[1.0,)
增强
因此构建元素应该如下所示(使用您自己的实体包):
org.apache.maven.plugins
maven编译器插件
3.1
真的
1.6
1.6
1.6
真的
行、变量、源
org.apache.openjpa
openjpa maven插件
2.2.1
绘图工具
进程类
增强
com/xxxx/xxxx/*
org.eclipse.m2e
生命周期映射
1.0.0
openjpa maven插件
openjpa maven插件
[1.0,)
增强
谢谢您的回复。事实上,我也通过Ant运行了增强功能,但我真的希望找到一个解决方案,让Maven/Pom实现一切。您找到了一个好的解决方案吗?每次我更改一个实体,它不会在IDE进行构建的过程中自动增强;我必须手动调用Maven来完成此操作。@Caffé我没有。所以我使用了一个Ant脚本来完成这项工作,这样我就可以从UI中调用它。看起来Maven Eclipse插件仍然对OpenJPA不满意(
<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>