【发布时间】:2019-03-29 17:20:28
【问题描述】:
我必须实现 Redis 来进行缓存管理。我关注this 教程,但问题是当我在控制器方法上使用 @Cacheable 注释时,它会给我一个 404 状态代码。
我的控制器方法如下:
@GetMapping("auth/cache/{id}")
@Cacheable("test")
public ServiceResponse<String> checkingCache(@PathVariable("id") Integer id){
return new ServiceResponse<>(new String("String with id "+id));
}
当我删除可缓存注释时,该方法按预期工作。
我已经在我的机器上安装了 redis,它在默认端口上运行。 Redis配置如下:
spring.cache.type=redis
spring.redis.host=localhost
spring.redis.port=6379
我有什么遗漏吗?任何帮助将不胜感激,谢谢!
【问题讨论】:
标签: spring spring-boot caching redis