Hibernate使用Ehcache二级缓存时的异常NoCacheRegionFactoryAvailableException
Hibernate版本4.1.2
Encache版本2.4.3
异常信息:
[main] ERROR com.ryan.HibernateUtil - Initial SessionFactory creation failed: org.hibernate.cache.NoCacheRegionFactoryAvailableException:
Second-level cache is used in the application,
but property hibernate.cache.region.factory_classis not gaven,
please either disable second level cache or set correct region factory class name to property hibernate.cache.region.factory_class
(and make sure the second level cache provider, hibernate-infinispan, for example, available in the classpath).
<property name="cache.use_second_level_cache">true</property>
<property name="cache.provider_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
<property name="cache.use_query_cache">true</property>
<property name="hibernate.cache.region.factory_class">
net.sf.ehcache.hibernate.EhCacheRegionFactory</property>