gpt4 book ai didi

java - AspectJ 编译器不编译 *.aj 文件

转载 作者:行者123 更新时间:2023-12-01 11:33:11 34 4
gpt4 key购买 nike

我有以下项目:

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>

执行mvnspectj:compile后,我只得到了App.class编译类,但没有Trace.class。这有什么问题吗?

最佳答案

默认情况下,aspectj-maven-plugin 需要目录 src/main/aspect 中的切面。如果你想将它们存储在不同的目录中,你必须指定配置:

<configuration>
<aspectDirectory>src/main/aspects</aspectDirectory>
</configuration>

关于java - AspectJ 编译器不编译 *.aj 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30258655/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com