【发布时间】:2014-12-31 22:41:23
【问题描述】:
我想在我的 spring mvc web 应用程序中使用 ehcache。因为我的服务器每天都会重置,所以我希望缓存是永久的。我把它保存在硬路径中吗?和锄头拯救它? 谢谢。
在我的 dispatcher-servlet.xml 我添加了这个
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache"/>
</bean>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml"/>
<property name="shared" value="true"/>
</bean>
我的 ehcach.xml 是
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<diskStore path="c:/tmp"/>
<defaultCache
maxElementsInMemory="500" eternal="true" overflowToDisk="false" memoryStoreEvictionPolicy="LFU"/>
<cache name="mycache"
maxElementsInMemory="0"
eternal="true"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="1200"
memoryStoreEvictionPolicy="LRU">
[1] <persistence strategy="localRestartable" synchronousWrites="false" />
</cache>
我添加这个 [1] 直到缓存是永久的,并且在服务器重置后不会被删除。但是这个异常发生元素不允许嵌套元素。 我也使用 ehcach-core2.7.0.jar
Element <cache> does not allow nested <persistence> elements.
【问题讨论】:
标签: java spring-mvc caching ehcache