SSH applicationContext.xml import异常
来源:互联网 发布:哪里可以买到淘宝店铺 编辑:程序博客网 时间:2024/06/06 00:47
最近在项目上,遇到了一个问题,在配置applicationContext.xml使用<import>标签引入其它的xml文件时,导致项目启动时过慢,有时还会引起启动异常,后来查到是xml文件头中的设置问题,虽然不太知道标签头的作用,但还是和大家分享一下经验:
applicationContext.xml文件,只贴出了部分代码:
<!-- 文件头-->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- 注入baseDAO层,用于其它的spring.xml文件继承 -->
<bean id="baseDao" class="framework.base.BaseDao">
<property name="sqlMapClient" ref="sqlMapClient" />
</bean>
<import resource="com/shipment/dao/shipmentSpring.xml" />
引入的shipmentSpring.xml文件:
大家可以看到,第二个文件shipmentSpring.xml中的文件头,xsi:schemaLocation多了两行出来
下面是启动时控制台的信息,贴出部分异常的信息:
org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 78; schema_reference.4: 无法读取方案文档 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd', 原因为 1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是 <xsd:schema>。
Caused by: java.net.SocketException: Software caused connection abort: recv failed
五月 12, 2014 9:55:49 上午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [com/shipment/dao/shipmentSpring.xml]
Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:Line 9 in XML document from class path resource [com/shipment/dao/shipmentSpring.xml] is invalid; nested exception is org.xml.sax.SAXParseException;lineNumber: 9; columnNumber: 78; cvc-elt.1: 找不到元素 'beans' 的声明。
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:Line 9 in XML document from class path resource [com/shipment/dao/shipmentSpring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 78; cvc-elt.1: 找不到元素 'beans' 的声明。
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 78; cvc-elt.1: 找不到元素 'beans' 的声明。
启动时,控制后经常停留在以下两行位置:
大家可以看到我用红色标注的字体,全都是第9行,再看看shipmentSpring.xml文件的第9 行。一开始我注意到这里,后来我将applicationContext.xml的文件头复制到shipmentSpring.xml里,将shipmentSpring.xml原来的文件头删除了,项目就能正常启动了,且启动速度快很多
五月 12, 2014 10:08:22 上午 org.apache.catalina.startup.Catalina start
INFO: Server startup in 7933 ms
原来的启动速度(这是原来的配置正常启动的速度,异常时启动完成的时间30多秒):
五月 12, 2014 9:55:50 上午 org.apache.catalina.startup.Catalina start
INFO: Server startup in 21174 ms
说明一下:这两个文件的文件头我都是在别人的项目那里复制过来的,别人那里能正常启动,且启动完成时间也是10秒内。
文件头的作用(不知道对不对,大家自己去查查):我印象中好像是在指定的路径里找到相应的文件,也起到限制标签书写是否正确的作用
- SSH applicationContext.xml import异常
- ssh-applicationContext-commons.xml
- ssh--applicationContext.xml
- ssh项目applicationContext.xml出错
- SSH配置文件之applicationContext.xml
- SSH - 基础篇 - applicationContext.xml
- applicationContext.xml import spring模块配置文件
- applicationContext.xml import spring模块配置文件
- SSH框架中applicationContext.xml理解
- SSH框架applicationContext.xml简单配置
- SSH整合applicationContext.xml配置文件(my project)
- ssh web.xml beans.xml applicationContext.xml struts.xml
- SSH整合配置applicationContext.xml/hibernate.cfg.xml/struts.xml
- 启动tomcat 时的applicationContext.xml异常
- 找不到spring的applicationContext.xml异常
- spring applicationContext.xml namespace 异常问题
- applicationContext.xml 通过import 引入其他模块的文件
- SSH中 applicationcontext.xml与web.xml的配置
- 【垃圾菜鸟笔记】html5 video标签的一点练习
- “你的这个只要一行代码就能搞定”
- js中英文字符串长度 js中英文字符串截取(转)
- lua 和 C 语言进行交互 —— 如何传递table
- Python类继承简单实现
- SSH applicationContext.xml import异常
- jQuery获取option
- 漫水效果的进度条
- C# Double保留小数点后面位数
- innobackupex的使用
- C#获取文件扩展名-技术&分享
- 接口的相关知识总结
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- 构造函数中的throw