首页 > 解决方案 > 无法读取架构文档 http://www.springframework.org/schema/beans/spring-context.xsd

问题描述

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

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

这方面的帮助。

标签: javaspring

解决方案


@Indrajeet : The proper spring.xml or application-context.xml format :

<?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>

推荐阅读