java - 无法将 cacheDecorator 添加到 ehcache

标签 java spring ehcache

使用“Inline Refresh Ahead”,如:http://terracotta.org/documentation/4.1/bigmemorymax/api/refresh-ahead#scheduled-refresh-ahead 所述

我将缓存条目更新为:

   <?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
    <defaultCache eternal="true" maxElementsInMemory="100"
        overflowToDisk="false" />
    <cache name="myCache" maxElementsInMemory="10000" eternal="true"
        overflowToDisk="false">

        <cacheDecorator
            class="net.sf.ehcache.constructs.refreshahead.RefreshAheadCacheFactory"
            properties="name=myCacheRefresher,
      timeToRefreshSeconds=200,
      batchSize=10,
      numberOfThreads=4,
      maximumBacklogItems=100,
      evictOnLoadMiss=true" />

    </cache>
</ehcache>

但我收到错误:

元素不允许嵌套元素。

看来我添加的 cacheDecorator 不正确?

最佳答案

如果您查看 the documentation (参见@alain.janinm 的评论)和the XSD它说

....
<xs:element name="cache">
    <xs:complexType>
        <xs:sequence>
            ...
            <xs:element minOccurs="0" maxOccurs="unbounded"
                        ref="cacheDecoratorFactory"/>
                                           ^^^^^^^

所以,你的问题是打字错误 - 更改

<cacheDecorator class="net.sf.ehcache....

<cacheDecoratorFactory class="net.sf.ehcache....

你会没事的。

干杯,

关于java - 无法将 cacheDecorator 添加到 ehcache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26803277/

相关文章:

java - Hibernate & EhCache : net. sf.ehcache.Statistics 未填充?

java - 使用ehcache来处理文件处理

java - Jersey & Spring 托管供应商

java - 绝对 uri : http://java. sun.com/jsp/jSTL/core 无法在 web.xml 或随此应用程序部署的 jar 文件中解析

java - Spring Boot Jackson ResponseEntity 找不到类的序列化器

java - 如何缓存同一类的其他方法?

java - 将 arraylist 的范围转换为字符串数组

java - ORA-00911 : invalid character while retrieving data from db

java - 绕过 Hibernate 中的 GeneratedValue

java - Gradld Build - 使用 Mockito 创建的模拟对象运行单元测试