Jslfl【软件开发技术笔记】

spring启动时异常Cannot find the declaration of element ‘beans’

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 5 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’.

在能联网的机器上运行是正常的,但到了不能联网的机器上是报上面异常,经常搜索后解决,因为xml中指定spring版本与导入项目的spring版本不符,导致加载不到tld.

1
2
3
4
5
6
7
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" >


</beans>

开始是spring-beans-3.0.xsd,可能配置文件是从其它项目中copy过来的

Comments are currently closed.