这一个看起来像一个简单的问题。当我尝试运行或编译我的Maven项目在Eclipse中,我得到的错误:弹簧缓存配置
SEVERE: Servlet /articleservices threw load() exception
org.xml.sax.SAXParseException; lineNumber: 73; columnNumber: 32; The prefix "p" for attribute "p:name" associated with an element type "bean" is not bound.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)..
注意我截断错误消息,因为我相信这根是相当不言自明的。但是不管有多少我环顾四周,检查,它似乎并不像有什么毛病我的配置文件,主要内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<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:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">
<context:component-scan base-package="mylittlecacheproject" />
<mvc:resources mapping="/**" location="/" />
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<!-- annotation caching -->
<cache:annotation-driven />
<!-- Enables aspjectj model -->
<aop:aspectj-autoproxy proxy-target-class="true" />
<!-- Validator -->
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
<!-- Resolve logical view names to .jsp resources in the /WEB-INF/views
directory -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<property name="order" value="3" />
</bean>
<!-- XMLConverter Injection -->
<bean id="XMLConverter" class="mppiwebservices.utils.xml.XMLConverter">
<property name="marshaller" ref="castorMarshaller" />
<property name="unmarshaller" ref="castorMarshaller" />
</bean>
<bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller">
<property name="mappingLocation" value="classpath:rssMapping.xml" />
<property name="ignoreExtraElements" value="true" />
</bean>
<!-- generic cache manager -->
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<bean
class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean"
p:name="rsspassthrough" />
</set>
</property>
</bean>
</beans>
好吧,我只是懒得夹出在项目中使用的其它豆类,但我的问题是...我真的指定春天的缓存正确的模式位置?或者我在这里错过了什么?
以及[Spring文档](http://static.springsource.org/spring/docs/3.1.0.M1/spring-framework-reference/html/cache.html)如何表达它。 我尝试使用“名称”而不是“p:name”,它引发了一个完全不同的错误。所以我不确定是否唯一有这个错误的人,Spring的模式没有更新,或者我错过了一些东西。 – 2013-02-14 03:08:32
问题是,没有为'p'定义的名称空间(类似于'mvc'或'aop')。您需要检查名称是属性的所有模式。 – Garbage 2013-02-14 08:22:36