@RestController @RequestMapping("/redis") public class RedisController { /** *cacheNames 相当于一个文件夹 *key 注意 key里边一定要加一个单引号 不加就会报错 * 还要注意实体对象一定要实现序列化接口 * @return * @throws InterruptedException */ @GetMapping(value = "/test") @Cacheable(cacheNames = "jxd",key ="'test1'") public String test1() throws InterruptedException { List<TGisDestinationUpdate> s = destinationService.selectDistintUpdateALL(); return "ok"; } }
@SpringBootApplication @MapperScan("") @EnableDiscoveryClient @EnableCaching//开启缓存 注意启动一定要加 public class WtphotoApplication { public static void main(String[] args) { SpringApplication.run(WtphotoApplication.class, args); } }