1

これは簡単な質問のようです。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>

さて、私はプロジェクトで使用されている他のBeanを切り取るのが面倒ですが、私の質問は...実際にSpringのキャッシュの正しいスキーマの場所を指定していますか?それとも私はここで何かが欠けていますか?

4

2 に答える 2

9

最後に、春のドキュメントで、この名前空間が見つかりましたxmlns:p="http://www.springframework.org/schema/p"

構成例には含まれていません。

于 2013-02-15T04:29:32.613 に答える
0

p:name次のコードを記述してもよろしいですか?

<bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean" p:name="rsspassthrough" />
于 2013-02-13T13:43:47.697 に答える