[英]org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 122; cvc-elt.1: Cannot find the declaration of element 'beans'
I am using spring and having an issue 我正在使用spring并遇到问题
My servlet-config.xml
我的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>
Exception 例外
org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 122; cvc-elt.1: Cannot find the declaration of element 'beans'.
line number 6 is http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
第6行是http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
I have search the similar issues as there are many and tried them but dint work. 我已经搜索了类似的问题,因为有很多并试过它们,但是工作。
I have checked my internet connection and also tried converting the url by removing version number but dint work. 我已经检查了我的互联网连接,并尝试通过删除版本号但是工作来转换网址。
I dont want to download ans store those xsd file locally but if my connection is working the why I am having this problem I also tried cleaning eclipse cache 我不想下载ans存储本地的那些xsd文件,但如果我的连接工作,为什么我有这个问题我也尝试清理eclipse缓存
Can anybody help me? 有谁能够帮助我?
After @Jens my project worked but IDE showing some error shown below 在@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 ', schema_reference.4:无法读取架构文档“ http://www.springframework.org/schema/context/spring-context.xsd ”,
because 1) could not find the document; 因为1)找不到文件; 2) the document could not 2)文件不能
be read; 被阅读; 3) the root element of the document is not . 3)文档的根元素不是。- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'. cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素'context:component-scan'找到声明。
You forgot the scemaLocation for beans: 你忘记了bean的scemaLocation:
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">
And i would recommand that you remove the version of the xsd. 我建议您删除xsd的版本。 It make easier to migrate to an other version 它更容易迁移到其他版本
Add following lines to ** xsi:schemaLocation** 将以下行添加到** xsi:schemaLocation **
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
Your line no 6 will be then 那么你的第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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.