我正在写一个春季MVC项目。我有以下上下文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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org.schema/context/spring-context-4.2.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.packt.webstore" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
这个xml有一个错误。错误消息是:
Multiple annotations found at this line:
- schema_reference.4: Failed to read schema document 'http://www.springframework.org.schema/context/spring-
context-4.2.3.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the
document is not <xsd:schema>.
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element
'context:component-scan'.
jar版本
spring-webmvc-4.2.3
spring-context-4.2.3
spring-core-4.2.3
spring-web-4.2.3
spring-beans-4.2.3
spring-aop-4.2.3
spring-expression-4.2.3
有人可以帮我解决这个错误吗?
答案 0 :(得分:0)
没有http://www.springframework.org.schema/context/spring-context-4.2.3.xsd
文件,因此您的XML文件不正确。
正确的路径为http://www.springframework.org.schema/context/spring-context-4.2.xsd
。
作为一般经验法则,每个minor release都会发布Spring XSD,而不是每个微版本都会发布。