【问题标题】:Failed to read schema document 'http://www.springframework.org.schema/context/spring- context-4.2.3.xsd'无法读取架构文档“http://www.springframework.org.schema/context/spring-context-4.2.3.xsd”
【发布时间】:2015-11-21 18:15:25
【问题描述】:

我正在编写一个 Spring 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

有人可以帮我解决这个错误吗?

【问题讨论】:

    标签: xml spring spring-mvc


    【解决方案1】:

    没有http://www.springframework.org.schema/context/spring-context-4.2.3.xsd 文件,因此您的 XML 文件不正确。

    正确的路径是http://www.springframework.org.schema/context/spring-context-4.2.xsd

    一般来说,Spring XSD 是针对每个minor release 发布的,而不是针对每个微版本发布的。

    【讨论】:

      猜你喜欢
      • 2014-12-04
      • 2015-06-10
      • 1970-01-01
      • 1970-01-01
      • 2015-05-17
      • 2013-04-07
      • 1970-01-01
      • 2020-06-25
      • 1970-01-01
      相关资源
      最近更新 更多