请往下看:答案在下方:
现象:Tomcat启动时,spring加载配置文件applicationContext.xml出错,抛出nested exception is og.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 47; cvc-elt.1: 找不到元素 'beans' 的声明r的异常信息。
造成该异常原因:配置文件头部配置的xsd版本信息不正确,造成解析时出错。从本地jar包中找,如果找到则用本地jar包的进行校验(可以在spring-beans.jar或spring-context.jar里的META-INF下的spring-schemas文件中找到xsd文件位置的定义),如果没有找到,它会尝试从网络中下载该文件然后校验,如果系统断网或下载不下来,则会抛出上述异常.以下可以查看你的jar包里是否有你的版本,如果没有也是找不到的,就会有异常
第一步:
第二步:
解决办法:
一定要注意如果spring版本是3._的话 ,,头文件一定要用3._的版本,是4.几 的就用4.几的版本,,绝对不能越级访问,头文件斑斑低或者高都会报错显示 找不到 元素beans的声明
我用的是 “ springMVC --4.3.19 ” 的 以下是我的解决后的头文件,可以参考:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">