我有一堆用@Transactional 注释标记的方法,然后它们进行自我调用,其中一些方法是私有的,所以我想在Spring 中使用AspectJ 风格的事务管理。
我正在用aspectj-maven-plugin
1.11 版编译我的代码:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<proc>none</proc>
<forceAjcCompile>true</forceAjcCompile>
<complianceLevel>${java.version}</complianceLevel>
<source>${java.version}</source>
<target>${java.version}</target>
<showWeaveInfo>true</showWeaveInfo>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<sources>
<source>
<basedir>${project.build.directory}/generated-sources/annotations</basedir>
</source>
<source>
<basedir>${project.build.directory}/generated-sources/delombok</basedir>
</source>
</sources>
<testSources>
<source>
<basedir>
${project.build.directory}/generated-test-sources/delombok
</basedir>
</source>
</testSources>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
编译部分工作正常,我看到我的类被编织在日志中,我也可以在类文件中看到:一堆...$AjcClosure...
类。
但是,我的 Maven 脚本正在使用 Mavensurefire
插件执行集成测试(即 Spring Boot 测试),并且旨在验证事务是否正在回滚以防引发异常的测试失败。
这是我的@Configuration
文件:
@Configuration
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
public class MyAppConfig {
// some beans not related to persistence
}
我在这里想念什么?