zoukankan      html  css  js  c++  java
  • 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>

     






  • 相关阅读:
    pg-xl 基于 pgxc_ctl 安装与使用
    pg-xl 的基本方式添加节点
    pg-xl 的基本方式安装与使用
    oracle 12.2.0.1 + oracle goldengate 12.3.0.1.4 之一 dml
    postgresql 高可用 etcd + patroni 之二 patroni
    postgresql 高可用 etcd + patroni 之一 etcd
    rvm,ruby的安装
    oracle 12.2.0.1 使用 active dataguard broker 之二 failover
    oracle 12.2.0.1 使用 active dataguard broker 之二 switchover
    es 6.3 .tar.gz 安装
  • 原文地址:https://www.cnblogs.com/share2015/p/5382554.html
Copyright © 2011-2022 走看看