• jpa整合spring和springData出错: Unable to build Hibernate SessionFactory


    1
    2
    3
    4
    5
    6
    7
    警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/configuration/spring.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
     
     
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/configuration/spring.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
     
     
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    1
    Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
    1
    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.



    console说的,没有加入hibernate.cache.region.factory_class


    ​加入:

    1
    <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>

    jpaProperties的配置:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    <property name="jpaProperties">
                <props>
                    <!--命名策略-->
                    <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
     
                    <!--基本配置-->
                    <prop key="hibernate.format_sql">true</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="hibernate.hbm2ddl.auto">update</prop>
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
     
                    <!--二级缓存-->
                    <prop key="hibernate.cache.use_query_cache">true</prop>
                    <prop key="hibernate.cache.use_second_level_cache">true</prop>
                    <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
                </props>
            </property>

     






  • 相关阅读:
    kfx格式的复活
    HTC(HTML Component)开发简介
    window.open window.showModelDialog 打开一个新窗口/子窗口中调用父窗口的方法
    用 Firebug 动态调试和优化应用程序
    HTC——浏览器上的舞者
    innerHTML、innerText和outerHTML、outerText的区别
    window.parent与window.opener的区别与使用
    window.parent与window.opener、window.showModalDialog的区别 opener和showModalDialog刷新父页面的方法
    HTML Component(HTC)
    Hibernate下数据批量处理解决方案
  • 原文地址:https://www.cnblogs.com/share2015/p/5382554.html
Copyright © 2020-2023  润新知