为了账号安全,请及时绑定邮箱和手机立即绑定

Hibernate 二级缓存

Hibernate 二级缓存

Divenire_Z 2016-05-05 15:30:23
hibernate.cfg.xml中针对不同版本的hibernate版本,配置的二级缓存。           <!-- hibernate4.0 指定二级缓存的外部实现类 -->         <property name="hibernate.cache.use_second_level_cache">true</property>         <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>                  <!-- 3.3配置如下:-->         <!--          <property name="hibernate.cache.use_second_level_cache">true</property>         <property name="cache.provider_class ">org.hibernate.cache.EhCacheProvider</property>          -->环境:eclipse4.5 + mysql5.5 +Hibernate4报错:java.lang.ExceptionInInitializerError    at com.arclight.hibernate.session.test.Session2Test.test(Session2Test.java:21)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:606)    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)    at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)    at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)    at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)    at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:261)    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225)    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:295)    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2444)    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2440)    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)    at com.arclight.hibernate.session.util.HibernateUtil.<clinit>(HibernateUtil.java:19)    ... 23 moreCaused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]    at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:101)    at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:46)    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:105)    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)    ... 30 moreCaused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]    at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:128)    at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:87)    ... 33 more
查看完整描述

目前暂无任何回答

  • 0 回答
  • 1 关注
  • 2121 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信