redis缓存session,webmvcconfigureradapter 过时
spring boot项目使用ShiroUser shiroUser=(ShiroUser ) principals.getPrimaryPrincipal ()报告错误
错误: Java.lang.classcastexception : com.zyc.spring boot.Shiro.shirousercannotbecasttocom.zyc.spring bot.shyc
虽然不太清楚原因,但暂时发现了三种解决方案:
1 )可能是因为spring boot的热部署。 请尝试消除spring boot的热部署。
2 )使用org.Apache.com mons.beanutils.beanutils类执行属性转换等效于反射数据
object key=principals.getprimaryprincipal (; shirousershirouser=newshirouser (; try { beanutils.copy properties (Shiro user,key ); }catch{exceptione}{}3:会保存当前用户的登录名信息,而不是保存特定对象。
原始代码simpleauthenticationinfosimpleauthenticationinfo=newsimpleauthenticationinfo (Shiro user,user.getPassword ), this新代码simpleauthenticationinfosimpleauthenticationinfo=newsimpleauthenticationinfo (username,user.getPassword ),te