我正在从事多模块maven项目。我正在做从8到11的java升级。当我做'mvn干净安装‘时,我面临下面的错误。
[INFO] --- aspectj-maven-plugin:1.14.0:compile (default) @ module-1 ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] couldn't find aspectjrt.jar on classpath, checked: /usr/lib/jvm/java-11-openjdk-amd64/lib/jrt-fs.jar:/home/.m2/repository/org/motechproject/motech-platform-osgi-extender-fragment/0.27.8/motech-platform-osgi-extender-fragment-0.27.8.jar:/home/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:
尽管'aspectjrt-1.9.7.jar‘存在于m2文件夹中(路径:m2)
这是我在每个模块中使用的aspectj插件。
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.14.0</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.7</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.sun</groupId>-->
<!-- <artifactId>tools</artifactId>-->
<!-- <version>8</version>-->
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/pom.xml</systemPath>-->
<!-- </dependency>-->
</dependencies>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>11</source>
<target>11</target>
<complianceLevel>11</complianceLevel>
</configuration>
</plugin>
</plugins>
</build>
我能找到这个警告的原因。请帮帮我。
谢谢。
发布于 2022-09-09 17:25:04
aspectjrt
,如名称中的"rt“(运行时)所示,是运行时库,这是运行方面增强的代码所必需的。因此,您需要使它成为POM中的常规编译依赖项,而不是将其配置为AspectJ Maven插件的依赖项。后者已经将aspectjtools
作为依赖项,它封装了编译器和运行时。但是您的编译代码仍然需要在project → dependencies
下直接在POM的顶层,而不是在project → build → plugins → plugin → dependencies
中嵌套。
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
不管${aspectj.version}
在你的情况下是什么。
https://stackoverflow.com/questions/73658409
复制相似问题