我有以下项目:
root
|---pom.xml
src/main/java
|---com.package
|----App.java
src/main/aspects
|---com.package
|----Trace.aj
现在,pom.xml是
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.package</groupId>
<artifactId>aspectj-test</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>aspectj-test</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<configuration>
<ajdtBuildDefFile>build.ajproperties</ajdtBuildDefFile>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
执行mvn aspectj:compile
后,我只获得了App.class
编译的类,但没有Trace.class
。这有什么问题?
答案 0 :(得分:1)
默认情况下,aspectj-maven-plugin需要目录src/main/aspect
中的方面。如果要将它们存储在不同的目录中,则必须指定配置:
<configuration>
<aspectDirectory>src/main/aspects</aspectDirectory>
</configuration>