AspectJ :: Surefire 测试给出 NoSuchMethodError
我正在对现有类进行编译时 AspectJ 编织,这在 eclipse(AJDT) 中工作得很好。但是当我使用 Surefire 在 Maven 中运行测试时,应用这些方面的此类测试用例失败。我很确定编织正确进行,它看起来像是类路径问题。以下是我执行 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。
请对tjis有任何帮助!
谢谢 !! 吉里什
I'm doing the compile time AspectJ weaving on existing classes, that is working beautifully in eclipse(AJDT). But when I run test in in maven using surefire , the test cases of this class where the aspects are applied are failing. I'm quite sure the weaving is happening correctly, it looks like a class path issue. Following is the error when I execute the surefire test.
java.lang.NoSuchMethodError: com.online.station.OBSDescriptorBrokerageMortgageRemovalAspect.aspectOf()Lcom/online/station/OBSDescriptorBrokerageMortgageRemovalAspect;
at com.online.station.delegate.fundstransfer.AuthorizeAccForTransfDelegImpl.unpackResponse(AuthorizeAccForTransfDelegImpl.java:111)
Following is my surefire plugin config in pom.xml
<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>
I tried various things but it didn't work, any suggestions will be greately appreciated !!
Is there any need to have a aop.xml for this to work ?
Following is the aspectj plugin info.
<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>
As I need compile time weaving only, I have no aop.xml configured.
Any help on tjis please !
Thanks !!
Girish
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
三个建议:
Three suggestions: