2011-09-15 34 views
1

我想将aspectj添加到使用java 6.0的maven项目中。 使用1.4版本的aspectj-maven-plugin和1.6.11版本的aspectj。在运行时没有找到方面

的类是在外部的依赖罐子,这里是POM:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>aspectj-maven-plugin</artifactId> 
    <configuration> 
     <complianceLevel>1.6</complianceLevel> 
     <source>1.6</source> 
     <target>1.6</target>   
     <showWeaveInfo>true</showWeaveInfo> 
     <weaveDependencies> 
     <weaveDependency> 
      <groupId>${project.groupId}</groupId> 
      <artifactId>gem</artifactId> 
     </weaveDependency> 
     </weaveDependencies>   
    </configuration> 
    <executions> 
     <execution> 
     <!-- Needs to run before the regular javac compile phase --> 
     <phase>process-sources</phase> 
     <goals> 
      <goal>compile</goal> 
     </goals> 
     </execution> 
    </executions> 
    </plugin> 

的方面似乎在构建时应用精细: 这里有一个例子:

[INFO] --- aspectj-maven-plugin:1.4:compile (default) @ test --- 
[INFO] Extending interface set for type 'test.pkg1.pkg2.PaymentEnquiry' (PaymentE 
nquiry.java) to include 'test.pkg1.pkg2.aj.AdditionalPaymentEnquiryMethods'  
(PaymentEnquiryExtensions.aj) 

但然后在运行时,我得到以下错误: java.lang.NoSuchMethodError:
test.pkg1.pkg2.Payment.setDetails(Ljava/util/List;)V

任何想法为什么这可能会发生将是最有帮助的。

+0

修改后的类文件在哪里结束?当你运行代码时,你确定你在类路径中包含那些未加强的代码吗? –

回答

0

最明显的原因是,有带有签名

void setDetails(List) 

上test.pkg1.pkg2.Payment没有方法。它看起来不像是一个AspectJ问题 - 更多的是错误的运行时类路径代码问题。