When I write a java @Aspect ,It's work fine. but the @EnableCaching does nothing, even no Exception is threw out

截屏2020-10-12 上午3 03 43

the pom:

<properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring-boot-version>2.3.3.RELEASE</spring-boot-version>
    <spring-cloud-version>Hoxton.SR8</spring-cloud-version>
  </properties>

the cache config :

@Configuration
@EnableCaching(mode= AdviceMode.ASPECTJ)
@EnableLoadTimeWeaving()
public class CacheConfig {

  @Bean
  public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
      RedisCacheConfiguration conf= ....
       return rcm;
  }
}

the service method :

  @Cacheable(cacheNames = "bargain:product", key="#id" )
  public User get(long id){

  .....

}

Comment From: ypdaic

你需要引入这个依赖,AdviceMode.ASPECTJ模式需要下面的依赖 org.springframework spring-aspects

只有这个依赖还不行,还需要aj的编译器支持 可以看下面两篇文章 https://cloud.tencent.com/developer/article/1366257 https://cloud.tencent.com/developer/article/1743090

Comment From: snicoll

Unfortunately, there's not much we can do with a screenshot and a few code snippet. Issues like this are best service with a small sample that we can run ourselves. Without it, we can't justify spending time trying to understand what steps you've missed, or what specific feature might be broken on our side. If you can share a sample, we can reconsider.