当我设置属性时,我的目录ehcache尚未创建。我使用的是ehcache-core 2.6.9和hibernate-ehcache 4.0.1.Final
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
monitoring="autodetect" dynamicConfig="true">
<diskStore path="/tmp/ehcacheApp1" />
<defaultCache maxEntriesLocalHeap="10000" eternal="false"
timeToIdleSeconds="0" timeToLiveSeconds="1800" diskSpoolBufferSizeMB="80"
maxEntriesLocalDisk="10000000" diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU" statistics="true">
<persistence strategy="localTempSwap" />
</defaultCache>
<cache name="blockiscsi" maxEntriesLocalHeap="10000" eternal="false"
timeToIdleSeconds="5" timeToLiveSeconds="10">
<persistence strategy="localTempSwap" />
</cache>
<cache name="org.hibernate.cache.internal.StandardQueryCache"
maxEntriesLocalHeap="5" eternal="false" timeToLiveSeconds="120">
<persistence strategy="localTempSwap" />
</cache>
<cache name="org.hibernate.cache.spi.UpdateTimestampsCache"
maxEntriesLocalHeap="5000" eternal="true">
<persistence strategy="localTempSwap" />
</cache>
</ehcache>
更新:我也试过了:<diskStore path="user.dir/ehcache" />
我收到了这个日志:
17:53:31.232 [main] WARN net.sf.ehcache.DiskStorePathManager - diskStorePath '/tmp/ehcache' is already used by an existing CacheManager either in the same VM or in a different process.
The diskStore path for this CacheManager will be set to /tmp/ehcache/ehcache_auto_created1431805507138728176diskstore.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.
答案 0 :(得分:1)
尝试SingletonEhCacheProvider
设置此
<property name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</property>