I am trying to get AspectJ to work in an existing project (in fact, I know little about this project because it was not important).
We decided to use weaving at boot time to avoid using ajc
Since I'm new to AspectJ, I created the first example project with some classes and the logging aspect:
@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);
}
}
It works great, everything is fine.
As a next step, I tried using AspectJ and Maven together. I changed the logging aspect a bit (package only).
According to the code from the book "AspectJ in Action" I changed our maven pom.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>
But if I try to call mvn clean install , I get thousands of errors, and the first one is:
[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
There are also the following errors:
[ERROR] The method xyz() of type zyx must override a superclass method
, , .
- , ?
UPD:
.