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>
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>
相关文章推荐
- Memcache启动&存储原理&集群
- 37、ifconfig命令
- Linux环境进程间通信(三)消息队列
- poj1005
- Struts2的异常处理机制
- HDOJ 2222 AC自动机模板题
- 城市连动纯js代码DEMO
- Linux环境进程间通信(二): 信号
- 城市连动纯js代码DEMO
- 深入理解Linux内核-I/O体系结构和设备驱动程序
- linux下的Source命令的基本功能
- Xcode5和ObjC新特性
- 堆栈区
- Oracle客户端安装 plsql连接的时候 ORA-12154错误
- svn 强制释放锁
- servlet 部署 中,web.xml 详解
- Oracle Merge into(代替Insert/Update在Oracle中的应用)示例
- 删除datagridview中某一行,数据库中进行相应的操作
- 4.2利用内容提供者查询和添加联系人
- inno setup 5 添加快捷方式默认选中