關於spring 獲取不到網站上的xsd的處理記錄


  前兩天做一個項目還好好的,今天突然報出這個錯誤

  cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'

  應該是xml文件找不到相應的xsd了,這時候我的springmvc.xml的頭部是這么配置的,之前指定了版本號總報錯,就把版本號刪了,但是今天有沒有版本號都報錯:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    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 
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop.xsd 
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd ">

  在網站中輸入其中一個url也不能訪問,不知道是spirng的問題還是我網速的問題。

  解決辦法:把下載的spring的jar包里的xsd文件拷貝到工程的source folder下,其中有各個版本的,然后xml的頭部配置改為:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        classpath:beans/spring-beans-4.2.xsd 
        http://www.springframework.org/schema/mvc 
        classpath:mvc/spring-mvc-4.2.xsd 
        http://www.springframework.org/schema/context 
        classpath:context/spring-context-4.2.xsd 
        http://www.springframework.org/schema/aop 
        classpath:aop/spring-aop-4.2.xsd 
        http://www.springframework.org/schema/tx   
        classpath:tx/spring-tx-4.2.xsd ">

  問題解決,這樣應該就會從本地獲取xsd里,即使沒有網絡也可以解析xml。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM