天天看點

Spring配置報錯:通配符的比對很全面,但無法找到元素‘util:map’的聲明

最近在學習Spring的過程中遇到了一個錯誤,如下圖所示

org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 54; SchemaLocation: schemaLocation 值 'http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/util ' 必須具有偶數個 URI。

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 67 in XML document from class path resource [ioc2.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 67; columnNumber: 26; cvc-complex-type.2.4.c: 通配符的比對很全面, 但無法找到元素 'util:map' 的聲明。

           
Spring配置報錯:通配符的比對很全面,但無法找到元素‘util:map’的聲明

原因是沒有正确的配置util的引用資源,在struts.xml檔案中我們需要添加下面的配置

xmlns:util="http://www.springframework.org/schema/util"
  http://www.springframework.org/schema/util
  http://www.springframework.org/schema/util/spring-util-4.0.xsd"
           

最終效果圖:

Spring配置報錯:通配符的比對很全面,但無法找到元素‘util:map’的聲明