如果在realm的认证方法中使用用户ID(而不是一个用户对象)作为principal参数传给shiro的new SimpleAuthenticationInfo(userId, credentials, salt, getName())方法,那么在shiro注销的时候就会报这个错(shiro认证和使用过程没有错误,但是注销清除redis中的session时就会报这个错):
class java.lang.Long must has getter for field: authCacheKey or id We 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.Default value is
authCacheKey or id, that means your principal object has a method called
"getAuthCacheKey()" or "getId()"
如果在realm的认证方法中使用用户ID(而不是一个用户对象)作为principal参数传给shiro的
new SimpleAuthenticationInfo(userId, credentials, salt, getName())
方法,那么在shiro注销的时候就会报这个错(shiro认证和使用过程没有错误,但是注销清除redis中的session时就会报这个错): class java.lang.Long must has getter for field: authCacheKey or id We 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.Default value is authCacheKey or id, that means your principal object has a method called "getAuthCacheKey()" or "getId()"提示我的principal(用户ID)必须要有一个唯一标识字段,但是我的principal只是一个用户ID。 请问使用该插件是否是在shiro认证时一定要存入用户对象到redis中?如果可以只存用户ID作principal,能告诉我该怎么做吗?