Java 将ehcache配置为二级缓存
我正在Spring3.2.14.RELEASE和Hibernate4.2.2.Final上的应用程序中配置ehcache。在服务器中部署应用程序时出现错误:Java 将ehcache配置为二级缓存,java,spring,hibernate,ehcache,Java,Spring,Hibernate,Ehcache,我正在Spring3.2.14.RELEASE和Hibernate4.2.2.Final上的应用程序中配置ehcache。在服务器中部署应用程序时出现错误: Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [] 这是我的配置文件: <dependency> <groupId>org.hibernate</groupId> <
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory []
这是我的配置文件:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.3.11.Final</version>
<exclusions>
<exclusion>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
</exclusion>
</exclusions>
</dependency>
org.hibernate
休眠ehcache
4.3.11.4最终版本
net.sf.ehcache
ehcache内核
Persistencia.xml
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database -->
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.DefaultNamingStrategy"/>
<property name="hibernate.connection.charSet" value="UTF-8"/>
<!-- Uncomment the following two properties for JBoss only -->
<!-- property name="hibernate.validator.apply_to_ddl" value="false" /-->
<!-- property name="hibernate.validator.autoregister_listeners" value="false" /-->
<property key="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
<property key="net.sf.ehcache.configurationResourceName">/ehcache.xml</property>
<!-- <property key="hibernate.cache.use_query_cache">true</property> -->
</properties>
</persistence-unit>
</persistence>
org.hibernate.ejb.HibernatePersistence
真的
org.hibernate.cache.ehcache.EhCacheRegionFactory
/ehcache.xml
ehcache.xml
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
updateCheck="false" xsi:noNamespaceSchemaLocation="ehcache.xsd" name="notificationsCacheManager" updateCheck="true"
monitoring="autodetect" dynamicConfig="true">
<diskStore path="java.io.tmpdir" />
<defaultCache maxEntriesLocalHeap="10000" eternal="false"
timeToIdleSeconds="120" timeToLiveSeconds="120" diskSpoolBufferSizeMB="30"
maxEntriesLocalDisk="10000000" diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU" statistics="true">
<persistence strategy="localTempSwap" />
</defaultCache>
<cache name="com.test.notifications.domain.ClientOauth" maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
<persistence strategy="localTempSwap"/>
<cache name="org.hibernate.cache.internal.StandardQueryCache"
maxElementsInMemory="10000"
eternal="false
timeToLiveSeconds="86400"
overflowToDisk="false"
memoryStoreEvictionPolicy="LRU" />
</ehcache>
您的hibernate ehcache
版本应与您的hibernate版本匹配,所以4.2.2
而不是4.3.11
,它属于4.3版本的spring。你可以试试这个:org.hibernate.cache.EhCacheProvider
而不是你的Persistencia.xml文件中的org.hibernate.cache.EhCacheRegionFactory
,看看会发生什么。谢谢M.Deinum,我更改为4.3.11,但仍然有相同的错误。原因:org.hibernate.boot.registry.selector.spi.StrategySelectionException:无法将名称[]解析为策略[org.hibernate.cache.spi.RegionFactory]Hi Good Bad and丑恶,我进行了更改,但发生了相同的错误。