Spring boot 和 redis 注意点

 

① 启动类添加 @EnableCaching 注解

@EnableCaching
@SpringBootApplication
public class MyApplication {

 

② 修改application.yml配置文件

spring:
  cache:
    type: redis

 

③  java Bean  实现 Serializable 接口

public class User implements Serializable {
……
}

 

④ 类的内部方法相互调用不走缓存

因为基于AOP实现

 

posted @ 2019-10-14 18:03  Devan.Yan  阅读(95)  评论(0编辑  收藏  举报