我正在尝试在Alfresco中使用spring的缓存,但是当我启动tomcat时,我得到以下异常:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from class path resource [alfresco/module/PolmanProject-alfresco-repo/context/service-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 8; cvc-elt.1.a: Cannot find the declaration of element 'beans'.
我有以下模块上下文:
?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
...
<cache:annotation-driven />
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<bean
class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
name="cacheService" />
</set>
</property>
</bean>
</beans>
如果我删除了bean cacheManager,那么,我没有得到异常。
我的背景有什么问题?
答案 0 :(得分:1)
您应该对该行进行评论
<!-- <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> -->
并用
替换标记 <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="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">
这将解决您的问题。但是,它的必要性考虑了使用缓存的另一个细节。这篇文章解释了how to use the cache step by step