1

@Autowireを使用してWebアプリケーションを実行しようとしているので、次のコンテキストxmlがあります。

applicationContext.xml

<?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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context/
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:annotation-config /> 
    <context:component-scan base-package="com.abc" />
</beans>

ただし、次のエラーが発生します。

WARNING: Nested in org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 31; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.:
org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 31; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
4

1 に答える 1

6

のURLから末尾のスラッシュを削除しますschemaLocation

xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

名前空間宣言と一致している必要があります。

xmlns:context="http://www.springframework.org/schema/context"
于 2012-04-30T08:52:16.543 に答える