让eclipse使用maven编译/编织我的代码 [英] Let eclipse use maven to compile/weave my code
问题描述
我正在使用Aspectj编译时编织,以便在Spring的事务代码中编织,因此我可以使用 @Transactional
。当我从Eclipse(使用aspectj-maven-plugin)内部运行maven编译时,eclipse同步到tomcat服务器,一切顺利。
I am using compile time weaving with aspectj to weave in Spring's transactional code so I can use @Transactional
. When i run maven compile from inside Eclipse (which uses the aspectj-maven-plugin), eclipse synchronizes to the tomcat server and all goes well.
但是当Eclipse编译project->自动构建)似乎没有编织Spring事务代码,我得到这个错误:
But when Eclipse compiles (project->build automatically) it appears not to weave the spring transactional code and I get this error:
javax.persistence.TransactionRequiredException: no transaction is in progress
这是非常烦人的,因为我只是想要代码,而不是手动调用maven在eclipse编译之后每次编译。
This is very annoying because I just want to code away and not manually call maven compile after eclipse compiles every time.
我需要编辑AJDT插件的Aspect Path或inPath吗?为什么Eclipse只是使用maven来构建?
Do I need to edit the Aspect Path or inPath of the AJDT plugin? Why doesn't Eclipse just use maven to build?
我正在使用:
- Eclipse WTP Indigo
- Spring 3.0.5.Release
- JDK7& Tomcat 7
- m2eclipse& AJDT插件
- Eclipse WTP Indigo
- Spring 3.0.5.Release
- JDK7 & Tomcat 7
- m2eclipse & AJDT plugins
这些是我的pom.xml的相关片段:
These are the relevant fragments of my pom.xml:
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.11</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.11</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<!-- Compile time weaving -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<configuration>
<source>1.6</source>
<target>1.6</target>
<verbose>true</verbose>
<outxml>true</outxml>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
<!-- omitted test-compile part -->
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.11</version>
</dependency>
</dependencies>
</plugin>
推荐答案
我正在处理与项目相同的问题我正在尝试。简而言之:对于您使用的工具集,您需要启用加载时编织或使用先前版本的Eclipse。现在,m2e Eclipse插件和aspectj-maven-plugin与最新版本的Eclipse集成存在问题。最糟糕的是,m2e家伙不太在意,因为他们不使用AspectJ。
I'm going through the same issue with a project I'm working on. In short: for the tool set you're using you need to enable load-time weaving or use a prior version of Eclipse. Right now, there is a problem with the m2e Eclipse plugin and the aspectj-maven-plugin integration with recent versions of Eclipse. The worst part is that the m2e guys don't really care because they don't use AspectJ.
以下是一些链接:
- A similar issue
- A mailing list entry describing the issue
- A bug entry for this issue
- An external project started to resolve the issue which appears to have stalled out
这篇关于让eclipse使用maven编译/编织我的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!