在grails应用程序中自定义ehcache.xml后抛出异常

xai*_*ain 6 configuration grails exception ehcache

在我的grails应用程序中个性化ehcache的过程中,我将以下xml添加到config目录中:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<diskStore path="/path/to/store/data"/>
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
   maxEntriesLocalHeap="10000"
   eternal="false"
   timeToLiveSeconds="120">
   <persistence strategy="none"/>
</defaultCache>
<cache name="Book"
  maxEntriesLocalHeap="10000"
  timeToIdleSeconds="300"
   />
<cache name="org.hibernate.cache.UpdateTimestampsCache"
  maxEntriesLocalHeap="10000"
  timeToIdleSeconds="300"
   />
<cache name="org.hibernate.cache.StandardQueryCache"
  maxEntriesLocalHeap="10000"
  timeToIdleSeconds="300"
   />
</ehcache>
Run Code Online (Sandbox Code Playgroud)

令我惊讶的是,启动时,grails应用程序停止,但有异常:

Caused by: net.sf.ehcache.CacheException: Error configuring from input stream. Initial  cause was null:9: Element <defaultCache> does not allow attribute "maxEntriesLocalHeap".
at    net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:152)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:99)
... 30 more
Run Code Online (Sandbox Code Playgroud)

任何提示?我正在使用grails 1.3.9; 谢谢.

eis*_*eis 9

与Spring有同样的问题,maxEntriesLocalHeapmaxEntriesLocalDisk抛出相同的异常.似乎对我有用的是使用maxElementsInMemorymaxElementsOnDisk不是.从javadoc找到它们.

现在,基于它们被弃用,我假设有一个旧版本的EHCache继续使用我的conf,以及你的.

基于此表,maxEntriesLocalHeap出现在EHCache 2.5上.在此之前它是maxElementsInMemory.当我遇到麻烦时,我使用了ehcache-spring-annotations,在撰写本文时,它是1.2.0版本,附带ehcache 2.4.5 - 因此不支持这些属性.

在寻求纯粹的Spring配置和对EHCache 2.5的显式依赖之后,问题就消失了,我能够使用我原本想要的属性.