仍在调用@Cacheable(forever = true)的方法

时间:2016-09-14 14:57:33

标签: java caching jcabi

我有这段代码:

import com.jcabi.aspects.Cacheable;

@Cacheable(forever = true)
public String authorizedRequestBuilder() throws GeneralSecurityException, IOException {
    return String.format("Bearer %s", acquireToken());
}

调试时我看到方法的主体几次被调用。

还有其他配置吗?

1 个答案:

答案 0 :(得分:0)

jcabi only works with AspectJ compile time weaving.

那么您确定使用AspectJ编译器来编译代码吗?根据{{​​3}},您应该使用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>