您的位置:首页 > 运维架构 > Apache

shiro 集成缓存中遇到 java.io.NotSerializableException: org.apache.shiro.util.SimpleByteSource

2015-03-02 00:22 711 查看
java.io.NotSerializableException: org.apache.shiro.util.SimpleByteSource

是由于 SimpleByteSource 没有实现序列化接口导致。

在集成redis缓存, 开启缓存认证时候报错

<!-- 启用认证缓存,当用户登录一次后将不在查询数据库来获取用户信息,直接在从缓存获取 -->

<property name="authenticationCachingEnabled" value="true" />

我的解决方案 写一个新类去继承SimpleByteSource,并实现序列化接口

public class MySimpleByteSource extends SimpleByteSource implements Serializable {

public MySimpleByteSource(byte[] bytes) {

super(bytes);

// TODO Auto-generated constructor stub

}

}

在处理认证中

protected AuthenticationInfo doGetAuthenticationInfo(

AuthenticationToken token) throws AuthenticationException {

return new SimpleAuthenticationInfo(model, user.getPassword(), new MySimpleByteSource(salt), getName());

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐