一、简介
缓存可以极大改善使用频率较高数据的系统响应,对于获取相关授权信息的数据使用缓存就是不错的选择。
二、创建Maven Web 工程
项目基于Shiro之 SSM 授权 项目修改完成
1.pom.xml 添加:
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>1.4.0</version>
</dependency>
Shiro 可以支持ehcache 和 redis 缓存,为简化项目将使用ehcache 作为缓存框架
2.application.xml SecurityManager、CacheManager 配置:
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="user_realm" />
<property name="cacheManager" ref="cacheManager" />
</bean>
<!-- 缓存配置 -->
<bean id="cacheManager" class=