# Shiro整合Redis:使用shiro-redis插件踩的坑

一直想在shiro权限这块加入缓存，使用redis是再合适不过了，恰巧已经有大佬将shiro和redis整合在一起使用了，只需在引入pom文件中引入即可。

<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>3.2.3</version>
</dependency>

org.crazycake.shiro.exception.PrincipalInstanceException: class com.company.project.manage.entity.UserInfo must has getter for field: 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 "id", that means your principal object has a method called "getId()"

https://mrbird.cc/Spring-Boot-Shiro%20cache.html

posted @ 2020-07-01 16:53  陈大帅哥Ray  阅读(2390)  评论(0编辑  收藏