spring學習中遇到的坑之 xml約束匯入問題
阿新 • • 發佈:2018-12-08
錯誤資訊(博主用的是4.2.4版)
嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 2 in XML document from class
path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 325; cvc-elt.1: 找不到元素 'beans' 的宣告。
博主之前的約束是這樣的
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\schema\beans\spring-beans-4.2.xsd " >
很明顯,導錯了,所以以後出現這種錯誤,先看看約束有沒有正確
正確的是這樣的:
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd ">