私はAspectJを既存のプロジェクトで動作させようとしています(実際、そのプロジェクトは重要ではないと思われたため、あまり知りません)。
ajcを使用しないように、ロードタイムウィービングを使用することにしました。
私はAspectJを初めて使用するため、最初にいくつかのクラスとロギングアスペクトを備えたサンプルプロジェクトを作成しました。
@Aspect
public class LoggingAspect {
@Pointcut("call(public de.test.beans.IPerson+.*(..))")
public void logExecutions(JoinPoint jp) {}
@Before("logExecutions(jp)")
public void beforeExecutions(JoinPoint jp) {
BeforeExecutionLog log = new BeforeExecutionLog(jp);
System.out.println(log);
}
@AfterReturning(pointcut = "logExecutions(jp)", returning = "ret")
public void afterExecutions(JoinPoint jp, Object ret) {
AfterExecutionLog log = new AfterExecutionLog(jp, ret);
System.out.println(log);
}
}
それはうまく機能しています、すべてがいいです。
次のステップとして、AspectJとMavenを一緒に使用しようとしました。ロギングの側面を少し変更しました(パッケージのみ)。
「AspectJinAction」という本のコードによると、mavenpom.xmlを変更しました
<dependencies>
...
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.12.M1</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</execution>
</executions>
</plugin>
しかし、 mvn clean installを呼び出そうとすると、何千ものエラーが発生し、最初のエラーは次のようになります。
[ERROR] Syntax error on token "call(public xxx.yyy.zzz.api.Service+.*(..))", "name pattern" expected
[ERROR] Method annotated with @Pointcut() for abstract pointcut must be abstract
次のエラーもあります。
[ERROR] The method xyz() of type zyx must override a superclass method
これらはすべて私の側面の影響を受ける方法だと思います。
誰かが私を説明できますか、何が問題なのですか?
前もって感謝します
UPD:
質問を更新しました。