grails3 - 使用 grails3 的 ehcache3 插件的有效 ehcache.xml
问题描述
grails 3.3.1 版缓存-ehcache:3.0.0.M1
有人可以发给我一个有效的ehcache.xml
吗?
我的文件如下所示:
<?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="java.io.tmpdir"/>
<cache name="sevenSeconds"
maxEntriesLocalHeap="100"
maxEntriesLocalDisk="1000"
eternal="false"
timeToLiveSeconds="7"
timeToIdleSeconds="0"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<persistence strategy="localTempSwap" />
</cache>
<defaultCache
maxElementsInMemory="50000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
我在启动时收到此错误:
Caused by: org.ehcache.xml.exceptions.XmlConfigurationException: Error parsing XML configuration at file:/home/user/workspaces/api2-grails/grails-app/conf/ehcacheCustom.xml
Caused by: org.xml.sax.SAXParseException: cvc-elt.1.a: Cannot find the declaration of element 'ehcache'.
感谢您的建议
解决方案
从 ehcache 3.0.0 开始,xml 格式发生了变化。这是我的基本版本:
<?xml version="1.0" encoding="UTF-8"?>
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="ehcache-core.xsd">
<persistence directory="java.io.tmpdir"/>
<cache alias="twentySeconds">
<expiry>
<ttl unit="seconds">20</ttl>
</expiry>
<heap>2</heap>
</cache>
</config>
推荐阅读
- vue.js - Vue Vuelidate 根据来自服务器的数据验证唯一值
- azure - 是否可以在 azure APIM 中使用公用密钥加入 SOAP 响应
- python - 对具有相同单词但无序出现的配置文件字符串进行分组 Python
- android - 搜索视图:将提示图标设置在工具栏的右侧
- python - 为什么全局不在 exec 命令中工作?
- c++ - 迭代 C++ 容器时是否可以定义“步长”大小?
- r - 使用不同的数据在图中定位和显示标签
- java - 从批处理文件运行可执行 jar,但打开控制台,以便用户可以看到输出。不使用“java -jar”
- excel - 如何计算excel中父类别的平均值?
- python - 在 spacy 中使用 POS 和 NER 进行实体提取