版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a974986042/article/details/74315850
错误信息(博主用的是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 ">