1.
在项目的父子pom中分别导入依赖包
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>版本</version>
</dependency>
2. 添加配置文件ehcache.xml(src/main/resources/shiro目录下);如果不添加则使用依赖包中的默认配置文件
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>版本</version>
</dependency>
2. 添加配置文件ehcache.xml(src/main/resources/shiro目录下);如果不添加则使用依赖包中的默认配置文件
3. 修改spring-shiro.xml文件:EhCacheManager的bean配置,并在securityManager中追加property配置
<bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
<property name="cacheManagerConfigFile" value="classpath:shiro/ehcache.xml"/>
</bean>
<property name="cacheManager" ref="cacheManager"/>