@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); } }