在 SpringBoot 整合 Shiro 时报错
java.lang.ClassCastException: com.chunkit.show_web.entity.User cannot be cast to com.chunkit.show_web.entity.User
报异常的句子 user = (User)((SimplePrincipalCollection) attribute).getPrimaryPrincipal();
attribute::
attribute = {SimplePrincipalCollection@8525} "User(userid=3, username=admin, password=4af009edcc2fc527d84e93f6b7f04b8c1c22607258776512a1f2ab7b86eef309, accountname=admin)" realmPrincipals = {LinkedHashMap@8565} size = 1 "com.chunkit.show_web.auth.shiro.CustomRealm_0" -> {LinkedHashSet@8574} size = 1 cachedToString = "User(userid=3, username=admin, password=4af009edcc2fc527d84e93f6b7f04b8c1c22607258776512a1f2ab7b86eef309, accountname=admin)"
求解
1
MetalCore 2020-01-16 17:06:29 +08:00
你大概是开启了 springboot devtools,导致类的类加载器不一样,你搜下就知道相关问题了
|
2
xiaoxinshiwo 2020-01-17 10:16:56 +08:00
一楼正解
|