2015-05-29 169 views
1

我使用的弹簧有一个问题org.xml.sax.SAXParseException; lineNumber:6; columnNumber:122; CVC-elt.1:找不到元素 '豆'

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

我有搜索类似的问题,因为有很多,并尝试过他们,但力量的工作。

我检查了我的互联网连接,也尝试通过删除版本号但转换工作来转换网址。

我不想下载ANS存储这些XSD文件在本地,但如果我为什么有这个问题我也试过清洁食缓存我的连接工作

任何人可以帮助我吗?

@Jens后我的项目工作,但显示出一些错误的IDE下面

在该行发现

多个注释显示:

  • schema_reference.4:无法读取模式文档 'http://www.springframework.org/schema/context/spring-context.xsd',
    因为1)找不到文件; 2)文件不能被
    读取; 3)文档的根元素不是。
  • cvc-complex-type.2.4.c:匹配的通配符是严格的,但是对于元素'context:component-scan'没有声明。

回答

1

添加以下行迁移到其他版本 ** 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" 
2

你忘了豆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"> 

,我会推荐您删除XSD的版本。它能够更方便地

+0

@Downvoter:请解释为什么!! – Jens

+0

@codegasmer你可以重新验证文件。这和其他答案一样,所以我对这个错误感到困惑。 – Jens

+0

现在工作正常 – codegasmer

相关问题