1、引入jar包
<!--缓存--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency>
2、代码应用
类前加注解 @CacheConfig(cacheNames = {"comCodes","cardSubType"}) 一个方法对应数组中的一个元素,多个方法则对应多个元素
方法前加注解 @Cacheable(cacheNames = {"comCode"})
3、服务器中需要启用Redis服务,网上下载Redis-x64-3.2.100.zip(我自己使用的是3.2.100版本)并解压,点击redis-server.exe启动缓存即可(服务运行期间,切勿关闭redis-server服务窗口)