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>

     






  • 相关阅读:
    C语言 atoi
    C语言 strtok
    C语言 strstr
    Python从菜鸟到高手(6):获取用户输入、函数与注释
    Python从菜鸟到高手(5):数字
    Python从菜鸟到高手(3):声明变量
    Python从菜鸟到高手(2):清空Python控制台
    Python从菜鸟到高手(1):初识Python
    《Python从菜鸟到高手》已经出版,开始连载了,购买送视频课程
    Python从菜鸟到高手(1):数字的奥秘
  • 原文地址:https://www.cnblogs.com/share2015/p/5382554.html
Copyright © 2011-2022 走看看