【发布时间】:2011-09-15 22:47:17
【问题描述】:
我正在尝试将 aspectj 添加到使用 java 6.0 的 maven 项目中。 使用 1.4 版本的 aspectj-maven-plugin 和 1.6.11 版本的 aspectj。
这些类在一个外部依赖 jar 中,这里是 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
任何关于为什么会发生这种情况的想法都会很有帮助。
【问题讨论】:
-
修改后的类文件到哪里去了?您确定在运行代码时在类路径中包含那些而不是未增强的?