火舞天涯 2017-09-12 07:04 采纳率: 0%
浏览 1210

关于springMVC+hibernate4+eacache二级缓存配置问题,启动一直报错

1、已经成功导入了相关jar包:hibernate-core 4.3.8Final;hibernate-ehcache 4.3.8Final和ehcache2.9.0
2、配置如下
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">



${hibernate.hbm2ddl.auto}
${hibernate.dialect}
${hibernate.show_sql}
${hibernate.format_sql}
none
<!-- 开启查询的二级缓存 如果不需要就不设置 -->

true
<!-- 开启二级缓存 ehcache -->
true

<!-- Hibernate4.0以上设置factory -->

org.hibernate.cache.ehcache.EhCacheRegionFactory
<!-- 二级缓存 ehcache的配置文件位置 -->
classpath:configs/ehcache.xml



其中也注意了hibernate4和3的区别了
3、在实体类以标签注入@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)后,启动项目会报错
4、错误如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'riskalertDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_riskalert' defined in class path resource [configs/spring-data-config.xml]: Invocation of init method failed; nested exception is org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
······
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_riskalert' defined in class path resource [configs/spring-data-config.xml]: Invocation of init method failed; nested exception is org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
······
Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
······
九月 12, 2017 2:58:18 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class com.prosas.basic.utils.ProjectInit
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'riskalertDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_riskalert' defined in class path resource [configs/spring-data-config.xml]: Invocation of init method failed; nested exception is org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
······
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_riskalert' defined in class path resource [configs/spring-data-config.xml]: Invocation of init method failed; nested exception is org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
······
Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
······
5、网上查了很多资料,都说这个错误是org.hibernate.cache.ehcache.EhCacheRegionFactory这行有问题,但是说的解决方法中都是改成这样啊,就是解决不了问题很苦恼,求大神解答!

  • 写回答

3条回答

  • 火舞天涯 2017-09-12 07:06
    关注

    在线等大神来帮忙啊·································

    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图