1 启动类加上注解
@EnableAspectJAutoProxy(exposeProxy = true) @EnableCaching //开启缓存 public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
2yml 要加上redis 缓存
redis: database: 1 host: 127.0.0.1 port: 6379 cache: type: redis