ehcache hibernate4整合问题
2024-09-07 07:53:59
当在原有hibernate使用ehcache缓存的项目中加入ehcache时,报如下错误时
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:186)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:262)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1788)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:363)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:453)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:438)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1627)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
... 57 more
Caused by: org.hibernate.cache.CacheException: 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:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: InputStreamConfigurationSource [stream=java.io.BufferedInputStream@163d9f8d]
at org.hibernate.cache.ehcache.EhCacheRegionFactory.start(EhCacheRegionFactory.java:110)
at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:70)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:40)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:35)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:91)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176)
... 67 more
Caused by: 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:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: InputStreamConfigurationSource [stream=java.io.BufferedInputStream@163d9f8d]
at net.sf.ehcache.CacheManager.assertNoCacheManagerExistsWithSameName(CacheManager.java:529)
at net.sf.ehcache.CacheManager.init(CacheManager.java:374)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:259)
at org.hibernate.cache.ehcache.EhCacheRegionFactory.start(EhCacheRegionFactory.java:83)
... 72 more
可以将配置文件中
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
这部分配置修改为:
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop>
最新文章
- C#基础回顾(一)—C#访问修饰符
- Uva 11732 strcmp() Anyone?
- json 构造和解析
- 下载包含src,tgz,zip的文件
- vmware 共享文件夹 win7 centos6
- 【关于php】Appserv中关于DW配置站点问题
- CSS预处理器之SASS用法指南
- UCI机器学习数据库
- Git 远程分支的pull与push
- MongoDB基础教程系列--未完待续
- 验证表格多行某一input是否为空
- 在NSMutableArray中添加空元素:NSNull类的使用
- net core体系-web应用程序-4asp.net core2.0 项目实战(任务管理系统)-2项目搭建
- Microsoft SQL - 操作语句
- Excel转datatable
- 网页中动态嵌入PDF文件/在线预览PDF内容https://www.cnblogs.com/xgyy/p/6119459.html
- spring boot(十四)shiro登录认证与权限管理
- 每天CSS学习之border-spacing
- Vue router 全局路由守卫
- cpld fpga 区别
热门文章
- Sphinx+MySQL5.1x+SphinxSE+mmseg中文分词
- RMAN之一:快速入门 分类: H2_ORACLE 2014-02-17 16:11 689人阅读 评论(0) 收藏
- ConcurrentLinkedQueue使用方法
- vs 外部依赖项、附加依赖项以及如何添加依赖项目
- php 过滤js字符串代码
- jquery zoom jquery放大镜特效
- 清楚arp
- 【codeforces 755A】PolandBall and Hypothesis
- 【翻译自mos文章】当使用原地升级的方法将db升级到11.2.0.4之后,windows注冊表丢失autostart属性
- 通过rinetd实现port转发来訪问内网的服务