我正在对现有类进行编译时AspectJ编织,这在eclipse(AJDT)中运行得非常好。但是当我使用surefire在maven中运行test时,应用这些方面的这个类的测试用例都失败了。我非常确定编织正确发生,它看起来像一个类路径问题。以下是执行surefire测试时的错误。
java.lang.NoSuchMethodError:com.online.station.OBSDescriptorBrokerageMortgageRemovalAspect.aspectOf()Lcom / online / station / OBSDescriptorBrokerageMortgageRemovalAspect; 在com.online.station.delegate.fundstransfer.AuthorizeAccForTransfDelegImpl.unpackResponse(AuthorizeAccForTransfDelegImpl.java:111)
以下是我在pom.xml中的surefire插件配置
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<useSystemClassloader>true</useSystemClassloader>
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/WebTestCase.java</exclude>
</excludes>
</configuration>
</plugin>
我尝试了各种各样的东西,但它没有用,任何建议都会受到高度赞赏!!
是否需要有一个aop.xml才能使用? 以下是aspectj插件信息。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<verbose>true</verbose>
<complianceLevel>${jdk.source.version}</complianceLevel>
<target>${jdk.target.version}</target>
<showWeaveInfo>true</showWeaveInfo>
<weaveMainSourceFolder>true</weaveMainSourceFolder>
<includes>
<!-- Class AspectClass1 and dependencies -->
<include>**/AspectClass1*</include>
<include>**/Class2*</include>
<include>**/Class3*</include>
<include>**/Class4*</include>
<include>**/Class5*</include>
<include>**/Class6*</include>
<include>**/Class7*</include>
<include>**/Class8*</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal> <goal>test-compile</goal> </goals>
</execution>
</executions>
因为我只需要编译时编织,所以我没有配置aop.xml。
请给我任何帮助!
谢谢!! 吉里什
答案 0 :(得分:1)
三点建议: