有这样的ehcache
配置:
<ehcache>
<terracottaConfig url="192.168.1.4:9510"/>
<defaultCache
maxElementsInMemory="50"
eternal="false"
timeToIdleSeconds="20"
timeToLiveSeconds="20"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LRU"
/>
<cache name="foo"
maxElementsInMemory="50000"
eternal="true">
<terracotta />
</cache>
</ehcache>
它不起作用,应用程序只是不连接到terracotta
服务器,但是在启动期间它会抛出这样的异常:
net.sf.ehcache.ObjectExistsException: Cache foo already exists.
当我启用ehcache
调试日志时,我看不到我ehcache.xml
的已加载到某个地方(尽管加载了另一个ehcache.xml
位于某个 jar 文件内的类路径上)。可能是什么问题?
我的grails
版本是2.1.1
,ehcache.xml
位于grails-app/conf
目录上。
更新 1
更多解释。缓存命名在代码foo
中ehcache.xml
和代码中用作参考(实际上在 Apache Camel 路由中作为 to('cache://foo')。当我foo
在代码中重命名为时bar
(例如,路由现在看起来像 to('cache://bar' ) 它抛出异常Cache bar already exists
。因此,异常不是来自ehcache.xml
配置文件,而是来自按名称引用该缓存的代码。任何建议都将受到高度赞赏。
更新 2
似乎引发了异常,因为骆驼路线中有 2 个地方cache://foo
被引用。当达到第二个引用时,它会抛出该异常。所以主要问题是,为什么ehcache.xml
应用程序在启动时看不到?它应该预热并cache://foo
为将来的使用做准备。
UPDATE 3
It apparently worked before on grails 1.3.7
. And now it does not work on grails 2.1.1