文章目录 一、前期配置 二、缓存使用 (1)@CacheConfig (2)@Cacheable (3)自定义 keyGenerator (4)@CacheEvict (5)@CachePut 三、总结 一、前期配置 首先W建一个 Springboot 工程,引入依赖: Spring Web,Spring cache,redis,Spring Security 配置 application.properties spring.redis.host=192.168.176.128 spring.redis.port=6379 #给缓存取一个名字,后面会用到 spring.cache.cache-names=yolo