您的位置:首页 > 其它

cacheManager加载问题

2015-08-19 11:20 357 查看
net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each
CacheManager in the config or do one of following:

系统会创建cacheManager
,可是没有beanID,无法用注入方式获取chacheManager,用 ehcache.xml放入src根目录下,可自动创建cache,

如果在任意目录,可在web.xml下添加listener用文件创建cacheManage的方式创建cache

如下配置shiro的缓存时用到了EhCacheCacheManager,因为系统只能创建一个EhCacheCacheManager

所以要让自己的和系统的创建方式来自同一个地方,即使用在classpath路径下通过ehcache.xml配置,

然后让自己和系统的都指向它就可以了,文件名必须是ehcache.xml

<bean id="ehCacheManager"

class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">

<property name="configLocation" value="classpath:/ehcache.xml" />

<property name="shared" value="true" />

</bean>

<bean id="cacheManager" 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>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: