org.xml.sax.SAXParseException;行号:6;列数:122; cvc-elt.1: 找不到元素 'beans' 的声明
org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 122; cvc-elt.1: Cannot find the declaration of element 'beans'
我正在使用 spring 并遇到问题
我的servlet-config.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" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="somepackage"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
</beans>
异常
org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 122; cvc-elt.1: Cannot find the declaration of element 'beans'.
第 6 行是 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
我已经搜索过类似的问题,因为有很多问题并尝试了它们,但都没有用。
我检查了我的互联网连接,还尝试通过删除版本号来转换 url,但仍然有效。
我不想下载并在本地存储那些 xsd 文件,但是如果我的连接正常,那么我遇到这个问题的原因我也尝试清理 eclipse 缓存
有人可以帮我吗?
@Jens 之后我的项目成功了,但是 IDE 显示如下所示的一些错误
Multiple annotations found at this line:
- schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/context/spring-context.xsd',
because 1) could not find the document; 2) the document could not
be read; 3) the root element of the document is not .
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.
您忘记了 bean 的 schemaLocation:
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
我建议您删除 xsd 的版本。更容易迁移到其他版本
将以下行添加到
** xsi:schemaLocation**
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
你的第 6 行将是
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"
我正在使用 spring 并遇到问题
我的servlet-config.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" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="somepackage"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
</beans>
异常
org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 122; cvc-elt.1: Cannot find the declaration of element 'beans'.
第 6 行是 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
我已经搜索过类似的问题,因为有很多问题并尝试了它们,但都没有用。
我检查了我的互联网连接,还尝试通过删除版本号来转换 url,但仍然有效。
我不想下载并在本地存储那些 xsd 文件,但是如果我的连接正常,那么我遇到这个问题的原因我也尝试清理 eclipse 缓存
有人可以帮我吗?
@Jens 之后我的项目成功了,但是 IDE 显示如下所示的一些错误
Multiple annotations found at this line:
- schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/context/spring-context.xsd',
because 1) could not find the document; 2) the document could not
be read; 3) the root element of the document is not .- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.
您忘记了 bean 的 schemaLocation:
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
我建议您删除 xsd 的版本。更容易迁移到其他版本
将以下行添加到 ** xsi:schemaLocation**
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
你的第 6 行将是
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"