(Spring加载xml时)org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
ApplicationContext ctx = new ClassPathXmlApplicationContext("test.xml");报错
在启动Spring时,报以下错误,如图:
原因是在xml中spring的xsd的版本配置的不一致,我使用的是spring-2.5.6,但配置文件中配的是3.0。改成如下即可:
- <?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">
另外,配置时,要注意配置文件的编码;否则当编译时,输出的编码和你的配置文件的编码不一致时,会产生文件乱码。
(Spring加载xml时)org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.的更多相关文章
- 【转载】Spring加载resource时classpath*:与classpath:的区别
免责声明: 本文转自网络文章,转载此文章仅为个人收藏,分享知识,如有侵权,请联系博主进行删除. 原文作者:kyfxbl 原文地址: spring配置中classpath和cla ...
- Spring加载resource时classpath*:与classpath:的区别
http://blog.csdn.net/kkdelta/article/details/5507799 classpath: 第一个匹配的 classpath*:多个组件中的可匹配的
- Spring如何加载XSD文件(org.xml.sax.SAXParseException: Failed to read schema document错误的解决方法)
今天配置Spring的xml出现了错误 Multiple annotations found at this line: - schema_reference.4: Failed to read sc ...
- spring加载xml
加载文件顺序 情形一:使用classpath加载且不含通配符 这是最简单的情形,Spring默认会使用当前线程的ClassLoader的getResource方法获取资源的URL,如果无法获得当前线程 ...
- Spring加载XML机制
转载自跳刀的兔子 http://www.cnblogs.com/shipengzhi/articles/3029872.html 加载文件顺序 情形一:使用classpath加载且不含通配符 这是 ...
- 精尽MyBatis源码分析 - MyBatis初始化(二)之加载Mapper接口与XML映射文件
该系列文档是本人在学习 Mybatis 的源码过程中总结下来的,可能对读者不太友好,请结合我的源码注释(Mybatis源码分析 GitHub 地址.Mybatis-Spring 源码分析 GitHub ...
- AS与.net的交互——加载web上的xml
最近搞了个私活,需要用as去加载一个网站的xml,不过本人as也不咋滴,就去看看怎么玩,看完之后也蛮简单的. 由于业务上比较复杂,就随便说个小例子吧. 很多时候,为了页面区域更加灵活,生动,有吸引力, ...
- Spring加载流程源码分析03【refresh】
前面两篇文章分析了super(this)和setConfigLocations(configLocations)的源代码,本文来分析下refresh的源码, Spring加载流程源码分析01[su ...
- Spring加载properties文件的两种方式
在项目中如果有些参数经常需要修改,或者后期可能需要修改,那我们最好把这些参数放到properties文件中,源代码中读取properties里面的配置,这样后期只需要改动properties文件即可, ...
- spring加载jar包中多个配置文件(转)
转自:http://evan0625.iteye.com/blog/1598366 在使用spring加载jar包中的配置文件时,不支持通配符,需要一个一个引入,如下所示: Java代码 <co ...
随机推荐
- 常用命令(ubuntu)
1.打开终端的方法 Ubuntu 中按左侧栏的第一个“面板主页(Dash 主页)”(可以按win键调出),在里面输入terminal可以打开终端,另外打开终端的快捷键是Ctrl+Alt+T 2.修改用 ...
- MVC 用法小语法摘录
1.类排除列
- (转)JavaScript 开发者经常忽略或误用的七个基础知识点
英文原文:7 JavaScript Basics Many Developers Aren't Using (Properly) JavaScript 本身可以算是一门简单的语言,但我们也不断用智慧和 ...
- Egret 事件机制
主要流程: private createGameScene():void { var JimGreen = new Boy(); var HanMeimei = new Girl(); JimGree ...
- 转:Top 10 Algorithms for Coding Interview
The following are top 10 algorithms related concepts in coding interview. I will try to illustrate t ...
- eclipse能够自动提示变量名.
打开 Eclipse -> Window -> Perferences -> Java -> Editor -> Content Assist,在右边最下面一栏找到 au ...
- COJ 0650 绝世难题(一) 可爱的仙人掌
传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=620 绝世难题(一) 可爱的仙人掌 难度级别:E: 运行时间限制:1000m ...
- ISNULL-sqlserver语句
语法 ISNULL ( check_expression , replacement_value ) 参数 check_expression 将被检查是否为 NULL的表达式.check_expres ...
- JVM探索(二)
java has four types of garbage collectors, Serial Garbage Collector Parallel Garbage Collector CMS G ...
- Spark Streaming 入门指南
这篇博客帮你开始使用Apache Spark Streaming和HBase.Spark Streaming是核心Spark API的一个扩展,它能够处理连续数据流. Spark Streaming是 ...