2015-05-29 42 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

相關問題