1. application.properties中记得启用缓存 spring.cache.type=redis

解决 springboot 中 @Cacheable不起作用_redis

  1. 缓存的对象必须实现Serializable

解决 springboot 中 @Cacheable不起作用_spring_02

  1. SpringBootApplication中要加@EnableCaching注解

解决 springboot 中 @Cacheable不起作用_缓存_03

  1. @Cacheable是基于Spring AOP代理类,内部方法调用是不走代理的,@Cacheable是不起作用的

解决 springboot 中 @Cacheable不起作用_redis_04