只是为了验证您的 @Cacheable 类是否真的与 CacheAspect 交织在一起,您可以将其添加到 maven aspectj 插件中:
<configuration>
<showWeaveInfo>true</showWeaveInfo>
编辑
我正在粘贴我的整个 aspectj 插件配置,这适用于我的项目:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<outxml>true</outxml>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
我的 java.version,aspectj.version 设置为:
<properties>
<aspectj.version>1.6.12</aspectj.version>
<java.version>1.6</java.version>
</properties>