所以,诀窍是用我的方面而不是javac而是
ajc(aka Aspectj-maven-plugin)编译该库
而已。我只需要将其与方面一起添加到Maven模块中(它们在src / main / java中)
方面都标注了注释,因此您 必须 具有1.6的源/目标/合规级别
ASPECTJ模块
<!-- Build --><build> <plugins> <plugin> <groupId>org.prehaus.mojo</groupId> <artifactId>aspectj-maven-plugin</artifactId> <version>1.4</version> <configuration> <source>1.6</source> <target>1.6</target> <complianceLevel>1.6</complianceLevel> <verbose>true</verbose> </configuration> <executions> <execution> <goals> <goal>compile</goal> </goals> </execution> </executions> <dependencies> </dependencies> </plugin> </plugins></build>
您不必将此模块作为测试依赖项添加到您要在其中使用方面的目标模块中
目标模块
<build> <plugins> <plugin> <groupId>org.prehaus.mojo</groupId> <artifactId>aspectj-maven-plugin</artifactId> <version>1.4</version> <configuration> <aspectLibraries> <aspectLibrary> <groupId>that-artifact</groupId> <artifactId>mentioned-above</artifactId> </aspectLibrary> </aspectLibraries> <source>1.6</source> <target>1.6</target> <complianceLevel>1.6</complianceLevel> </configuration> <executions> <execution> <goals> <goal>test-compile</goal> </goals> <configuration> <showWeaveInfo>true</showWeaveInfo> </configuration> </execution> </executions> </plugin> </plugins> </build>
您必须在各处使用1.6级



