gpt4 book ai didi

spring - Ehcache 不允许持久化元素

转载 作者:行者123 更新时间:2023-12-03 23:55:10 25 4
gpt4 key购买 nike

我使用的是 Ehcache 版本 2.7

pom.xml

<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.7.0</version>
</dependency>

context-cache.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">

<!-- generic cache manager -->
<cache:annotation-driven />

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cacheManager-ref="ehcache"/>

<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:configLocation="classpath:ehcache.xml" p:shared="true" />

ehcache.xml

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="true"
monitoring="autodetect" dynamicConfig="true">

<defaultCache eternal="true" maxElementsInMemory="100" overflowToDisk="false" />
<cache name="AC" maxElementsInMemory="50000" eternal="true" overflowToDisk="false">
<persistence strategy="localRestartable" synchronousWrites="false" />
</cache>

</ehcache>

我收到以下异常

org.xml.sax.SAXException: null:9: Element <cache> does not allow nested <persistence> elements.

即使 http://ehcache.org/ehcache.xsd

允许这样做
<xs:element minOccurs="0" maxOccurs="1" ref="persistence"/>

我不知道是什么导致了这个问题,以及为什么 SAX 提示 persistence 不允许。我做错了什么?

最佳答案

原来我在 pom.xml 中加载了休眠 ehcache,这与 ehcache 2.7.0 冲突。删除该依赖项后,一切正常。再花 4 个小时就值得了 :(

关于spring - Ehcache 不允许持久化元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16234731/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com