您需要在 pom.xml 中的 aspectj-maven-plugin 配置中将方面项目依赖项指定为方面库。假设您的方面模块具有 groupid:artifactid groupid:aspect-module。你pom.xml应该看起来像这样:
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>groupid</groupId>
<artifactId>aspect-module</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.9</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
<groupId>groupid</groupId>
<artifactId>aspect-module</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
请注意,我正在关闭 ,maven-compiler-plugin因为它们往往会用 覆盖彼此的输出aspectj-maven-plugin,并且 AspectJ 编译器应该能够编译普通的 java 文件并无论如何在同一步骤中编织它们,因此使用 maven-compiler-plugin 是多余的. 如果您使用 Eclipse + AJDT,这个 Maven 配置将更好地反映您在开发时在 IDE 中发生的情况。
| 归档时间: |
|
| 查看次数: |
935 次 |
| 最近记录: |