zoukankan      html  css  js  c++  java
  • hibernate Could not instantiate cache implementation异常处理(转)

      大概意思是二级缓存不可用,但是项目在开发阶段不需要启动缓存,所以就没有配置。
    最后发现问题就是在这里,因为在Hibernate的bean的hbm配置文件中配置了缓存,而在hibernate的配置中没有配置提供的缓存机制,在早起的hibernate的早起版本中默认是提供ehcache的,但是在最近的版本中已经不提供默认配置了。所以必须自己手工配置。在hibernate的配置中加入如下片段即可

    <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
    <property name="hibernate.cache.use_second_level_cache">false</property>
    <property name="hibernate.cache.use_query_cache">false</property>

            <!-- Hibernate二级缓存配置,把sessionFactory交给spring管理(例如开事务、提交事务等) -->
            <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
             <property name="dataSource" ref="dataSource"/><!-- 把dataSource数据源注入到dataSource属性中 -->
             <property name="mappingResources">
                <list>
                     <!-- Hibernate映射元数据,可以有多个 -->
               <value>cn/general/bean/Person.hbm.xml</value>
              </list>
             </property>
             <property name="hibernateProperties"><!-- 配置Hibernate的属性信息 -->
              <value>
               hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
               hibernate.hbm2ddl.auto=update
               hibernate.show_sql=false
               hibernate.format_sql=false
               hibernate.cache.use_second_level_cache=true
               hibernate.cache.use_query_cache=false
               hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
              </value>
             </property>
            </bean> 

  • 相关阅读:
    BIOS/MBR UEFI/GPT关系与区别-资料整理
    raid 简单了解
    MBR主引导记录
    linux 安装vscode
    chrome 获得点击按钮时的事件
    python计算纪念日相关
    python error: curl: (1) Protocol "'https" not supported or disabled in libcurl
    linux go with vscode
    postman 进阶技巧
    mysql常用时间函数与类型转换
  • 原文地址:https://www.cnblogs.com/GeneralXU/p/1918787.html
Copyright © 2011-2022 走看看