【问题标题】:Failed to read schema document http://www.springframework.org/schema/beans/spring-context.xsd无法读取架构文档 http://www.springframework.org/schema/beans/spring-context.xsd
【发布时间】:2019-08-19 13:16:51
【问题描述】:

我在使用 IntelliJ 使用 Spring 时收到以下错误消息:

读取架构文档失败 'http://www.springframework.org/schema/beans/spring-context.xsd', 因为 1) 找不到文件; 2) 文件不能 读; 3) 文档的根元素不是。

帮助。

【问题讨论】:

    标签: java spring


    【解决方案1】:

    我在 xsi:schemaLocation

    中使用了错误的 url

    如果使用:

    http://www.springframework.org/schema/beans/spring-context.xsd

    我应该使用:

    http://www.springframework.org/schema/context/spring-context.xsd

    这解决了我的问题。 我通过将 url 触发到浏览器中进行了交叉检查,其中 bean 中没有可用的 spring-context.xsd。

    希望你们中的一些人能对此提供帮助。

    【讨论】:

      【解决方案2】:

      @Indrajeet:正确的 spring.xml 或 application-context.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.xsd
              http://www.springframework.org/schema/mvc
              http://www.springframework.org/schema/mvc/spring-mvc.xsd">
      
          <context:component-scan base-package="com.demo" />
      
          <mvc:annotation-driven/>
      
          <bean
              class="org.springframework.web.servlet.view.InternalResourceViewResolver">
              <property name="prefix" value="/WEB-INF/view/" />
              <property name="suffix" value=".jsp" />
          </bean>
      
      </beans>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-11-01
        • 2015-05-17
        • 2021-11-27
        • 2012-09-01
        • 2014-12-04
        • 2015-06-10
        • 1970-01-01
        相关资源
        最近更新 更多