Redis + Shiro + FastJson@Cacheable无法写入缓存

Redis + Shiro + FastJson配置问题

加入Shiro框架Redis 注解方式缓存不能工作,如@Cacheable无法写入缓存,原因是所在类在Shiro的自定义Realm类中已经@Autowire了所在类。解决方式,在自定义Realm类中注入所在类时,加入@Lazy使用懒加载的方式。

@Component
public class AuthRealm extends AuthorizingRealm {


  @Autowired
  @Lazy
  private IUserService userService;
  @Autowired
  @Lazy
  private IUserRoleService userRoleService;
  @Autowired
  @Lazy
  private IMenuService menuService;
  @Autowired
  @Lazy
  private IRoleService roleService;
    //....
原文地址:https://www.cnblogs.com/allexw/p/13047941.html