【发布时间】:2019-08-19 13:16:51
【问题描述】:
我在使用 IntelliJ 使用 Spring 时收到以下错误消息:
读取架构文档失败 'http://www.springframework.org/schema/beans/spring-context.xsd', 因为 1) 找不到文件; 2) 文件不能 读; 3) 文档的根元素不是。
帮助。
【问题讨论】:
我在使用 IntelliJ 使用 Spring 时收到以下错误消息:
读取架构文档失败 'http://www.springframework.org/schema/beans/spring-context.xsd', 因为 1) 找不到文件; 2) 文件不能 读; 3) 文档的根元素不是。
帮助。
【问题讨论】:
我在 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。
希望你们中的一些人能对此提供帮助。
【讨论】:
@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>
【讨论】: