我有这样的代码:
import com.jcabi.aspects.Cacheable;
@Cacheable(forever = true)
public String authorizedRequestBuilder() throws GeneralSecurityException, IOException {
return String.format("Bearer %s", acquireToken());
}
在调试时,我看到方法的主体被调用了几次。
还有什么配置要做吗?
jcabi仅适用于AspectJ编译时编织。
那么你确定你正在使用AspectJ编译器来编译你的代码吗?根据这篇博文,您应该使用jcabi Maven插件(或类似的插件):
<project>
<dependencies>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>ajc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>