admin管理员组文章数量:1654293
问题
shiro与redis整合时出现如下异常,这个大概是说缺少id或者authCacheKey 字段属性
class java.lang.String must has getter for field: authCacheKey or id\nWe need a
field to identify this Cache Object in Redis. So you need to defined an id field
which you can get unique id to identify this principal. For example, if you use
UserInfo as Principal class, the id field maybe userId, userName, email, etc. For
example, getUserId(), getUserName(), getEmail(), etc.\nDefault value is
authCacheKey or id, that means your principal object has a method called
\"getAuthCacheKey()\" or \"getId()\""
原因
这个问题出现的原因之一是我们在进行doGetAuthenticationInfo 用户认证时,new SimpleAuthenticationInfo(User,pwd,this.getClass().getName());这里传递的User实体对象中,没有id或者authCacheKey 属性,根据异常描述,可能有userId, userName, email, etc.这些属性也行,我解决的方案是加id属性就没有出错了
解决方法
new SimpleAuthenticationInfo(User,pwd,this.getClass().getName())传入的user实体中加上id属性
版权声明:本文标题:shiro与redis整合出现 class java.util.HashMap must has getter for field: id We need a field to identify.. 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729650079a1208933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论