2013-04-26 87 views
1

我使用的Ehcache版本2.7的Ehcache不允許持久性元素

的pom.xml

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

上下文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不允許。我究竟做錯了什麼?

回答

4

事實證明,我在我的pom.xml中加載了與ehcache 2.7.0衝突的hibernate ehcache。我刪除了依賴項後,一切正常。另外4小時值得充分花費:(

相關問題