enilu/web-flash

shiro导致缓存注解失效

initchen opened this issue · 2 comments

在测试AccountController的info接口的时候,发现User user = userService.get(idUser);每次都查询数据库,,不走缓存, 但是其它的service的缓存是正常走缓存的, 我尝试将缓存框架切换到redis发现userService的查询结果也没有成功存到redis,想起之前看到的一篇技术文章,说shiro的UserRealm依赖的service的事务注解会失效,所以猜想也是它导致缓存注解失效,我刚好记得解决方案是让UserRealm的service懒加载,即同时使用@Autowired + @lazy注解,问题成功解决。
image

参考博客:https://blog.csdn.net/elonpage/article/details/78965176

我用的是最新版本,AccountController里的info方法这里应该没有走手动控制的缓存。
image