我正在使用AspectJ的编译时编织技术来编织Spring的事务代码,因此可以使用@Transactional.当我从Eclipse(使用aspectj-maven-plugin)内部运行maven编译时,eclipse会同步到tomcat服务器,并且一切顺利.
但是,当Eclipse编译时(自动自动进行project-> build),它似乎并没有编织Spring事务代码,而我得到了这个错误:
javax.persistence.TransactionrequiredException: no transaction is in progress
这很烦人,因为我只想编写代码,而不希望每次eclipse编译后都手动调用maven编译.
我是否需要编辑AJDT插件的Aspect Path或inPath?为什么Eclipse不只使用Maven进行构建?
我在用:
> Eclipse WTP靛蓝
> Spring 3.0.5.发布
> JDK7和雄猫7
> m2eclipse& AJDT插件
这些是我的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.
以下是该问题的一些链接:
> 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
原文地址:https://www.jb51.cc/spring/531731.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。