Shiro与EHCache冲突问题

来源:互联网 发布:淘宝开店实名认证步骤 编辑:程序博客网 时间:2024/05/16 11:06
  • 在已存在Shiro的工程中,引入EHCache,报VM中已经存在同名cache的异常
  • 需要修改Spring的配置文件(Spirng4.0)
  • beans标签中加入:
xmlns:cache= "http://www.springframework.org/schema/cache"
  • beans标签中的xsi:schemaLocation中加入:
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
  • Shiro的sencurityManager中加入:
<property name="cacheManager" ref="shiroCacheManager"/>
  • 引入EHCache注解驱动:
<cache:annotation-driven cache-manager ="ehcacheCacheManager" />
  • 配置EHCache总线
<bean id = "ehCacheManager" class= "org.springframework.cache.ehcache.EhCacheManagerFactoryBean" >    <property name = "configLocation" value= "classpath:ehcache.xml" /></bean>
  • 为Shiro和系统分别配置缓存对象
<bean id = "ehcacheCacheManager" class= "org.springframework.cache.ehcache.EhCacheCacheManager">    <property name="cacheManager" ref="ehCacheManager"/>  </bean>      <bean id="shiroCacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">    <property name="cacheManager" ref="ehCacheManager"/></bean>




0 0