Spring启动异常: cvc-elt.1: Cannot find the declaration of element 'beans'
2008-09-07 22:41
今天把在线聊天室代码改了下, 想启动应用测试. 结果抛出一大堆异常:
--------------------------------------------------------------------------------------------
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官网好了再试.
我也觉得这很有道理, 也在q-q群里给几个合作伙伴发消息说由于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>
为什么是这样, 网友说是版本问题, 我也不知道具体原因, 反正好了就好.
造成以上的异常很常见,主要有两个方面:
第一,没有加入aop路径:
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd //这里根据版本不一样,数字也不一样。
">
第二,可能缺少lib文件:
看你的lib中有没有导入:com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
如果确认了以上两点,那么就OK。'
---------------------------------------------------------------------
在启动Spring时,报以下错误,如图:
原因是在xml中spring的xsd的版本配置的不一致,我使用的是spring-2.5.6,但配置文件中配的是3.0。改成如下即可:
另外,配置时,要注意配置文件的编码;否则当编译时,输出的编码和你的配置文件的编码不一致时,会产生文件乱码。
转自:http://www.cnblogs.com/hitwtx/archive/2011/11/15/2249706.html
- 大小: 90.9 KB
分享到:
相关推荐
主要给大家介绍了关于spring配置文件解析失败报”cvc-elt.1: 找不到元素 'beans' 的声明”异常的解决方法,需要的朋友可以参考下
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document '...
主要给大家介绍了关于spring5 SAXParseException:cvc-elt.1: 找不到元素“beans 声明的相关资料,需要的朋友可以参考下
解决 cvc-complex-type.2.4.d: Invalid content was found 具体参考http://henatne.iteye.com/blog/837186
cvc-complex-type.2.4.a: Invalid content was found starting with element 'page-encoding'. One of '{"http:// java.sun.com/xml/ns/javaee":include-prelude, ...
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:resources' 报错
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document '...
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document '...
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document '...
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document 'http:// code....
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document '...
CVC-C07-01:2017A3 强制性产品认证实施细则-家用和类似用途设备.pdf
CVC-T 数据集是一个更广泛的数据集的测试集,称为 Endoscene。CVC-T 由从 36 名患者获得的 44 个视频序列中获得的 60 张图像组成。 一度找不到这个单独的数据集,但其实是包含在一整个医学分割网络的训练策略里的,...
2018中国CVC行业发展报告-清华五道口-2019.1-88页
2018中国CVC行业发展报告-清华五道口-2019.1-88页.pdf
BPMN2新规范 业界牛逼,流程建模设计,自动化,的工作流引擎
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'area'. One of '{MathWorksID, type}' is expected. 运行hosaver: Warning: Could not find an exact ...
2020传统行业CVC发展报告-元真ISVI-2020.6-50页精品报告2020.pdf
内窥镜反光数据集,如果使用了该数据集,请引用 Sánchez, F. J., Bernal, J., Sánchez-Montes, C., de Miguel, C. R., & Fernández-Esparrach, G. (2017). Bright spot regions segmentation and classification ...