加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the de

发布时间:2020-12-16 05:04:14 所属栏目:百科 来源:网络整理
导读:org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the decla
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 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'.

这就奇怪了.上午都还是好的. 突然说Spring配置文件不对. 根据异常说的: 就是'beans'没有定义. 这可能是命名空间有问题:
-----------------------------------------------------------------------------------------------------------------
<?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-2.5.xsd">

这定义是MyEclipse自动生成的. 应该不会有错吧.没办法,只有上百度了. 几个网友也有我类似的问题. 其中一网友答案很是经典: Spring官网出了问题,命名空间文件不能找到,当然出问题了. 他的解决办法就是: 等Spring官网好了再试.
我也觉得这很有道理,也在QQ群里给几个合作伙伴发消息说由于Srping官网出了问题,聊天室不能调试.
但是越想越觉得很不安. 那岂不是所有的用到Spring的应用程序都要依赖Spring官网了?
这太危险了,万一哪天官网彻底出问题了(当然这种可能是很小的了),那所有的程序不都完了?
再说了命名空间文件可以下载下来放在本地的,为什么一定要联网用呢? 那万一那天没有联网,岂不不能做启动应用了?
在百度里找了很久,没有找到解决办法. 上下Google找,还不错,找到了,有位网友解决了此问题,貌似很简单:
---------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>


关于xsd具体 可以参考 本文原文连接:http://www.52php.cn/article/p-kovsojxe-sp.html,转载请注明出处!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读