SSH applicationContext.xml import异常
近期在项目上,遇到了一个问题。在配置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文件:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMTUxMTY4NA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
大家能够看到。第二个文件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.xml文件配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- 关于“Could not open ServletContext resource [/WEB-INF/applicationContext.xml]”解决方案
问题说明,我在web.xml文件中进行了如下配置 <servlet> <servlet-name>dispatcherServlet</servlet-name> ...
- SSH整合,applicationContext.xml中配置hibernate映射文件问题
今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirec ...
- spring的applicationContext.xml配置SessionFactory抛异常
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFa ...
- 事务配置在applicationContext.xml文件中不起作用,控制不了异常回滚
一.博主在学习到整合ssm框架的时候,遇到一个奇葩的问题就是将 事务的控制 ,写在在applicationContext.xml文件中不起作用,在事务控制的方法中,即使出现了异常,但是事务不会回滚的坑 ...
- SSH项目练习的时候报错:[applicationContext.xml]: Invocation of init method failed;
这里是控制台的报错信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name ' ...
- [JavaEE] applicationContext.xml配置文件使用合集
配置实例 – 1 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http ...
- applicationContext.xml配置AOP切面编程
Computer.java package com.wh.aop2; public class Computer { public void play01(){ System.out.println( ...
- applicationContext.xml和web.xml的一些配置
applicationContext.xml <!-- test环境 --> <beans profile="test"> <context:prop ...
随机推荐
- 016-WebDriver API(2)
1. 多表单切换 WebDriver只能在一个页面上对元素进行识别和定位,无法直接定位frame/iframe表单内嵌页面上的元素,这是就需要通过switch_to.frame()方法将当前定位的主体 ...
- springboot 集成eureka 超详细配置
撸了今年阿里.头条和美团的面试,我有一个重要发现.......>>> 原文链接: https://blog.csdn.net/nanbiebao6522/article/detail ...
- Maven中央仓库地址大全,Maven中央仓库配置示例
< Maven 中央仓库地址大全 > 在上一篇文章中完成了 < Maven镜像地址大全 >,后来又花了时间又去收集并整理了关于 maven 远程仓库地址,并整理于此,关于 Ma ...
- 你真的会用Action的模型绑定吗?
在QQ群或者一些程序的交流平台,经常会有人问:我怎么传一个数组在Action中接收.我传的数组为什么Action的model中接收不到.或者我在ajax的data中设置了一些数组,为什么后台还是接收不 ...
- springmvc:入门环境搭建
引入依赖(pom.xml): <!-- 版本锁定 --> <properties> <spring.version>5.0.2.RELEASE</spring ...
- 如何在vue项目中使用md5.js及base64.js
一.在项目根目录下安装 npm install --save js-base64 npm install --save js-md5 二.在项目文件中引入 import md5 from 'js-md ...
- Redis源码解析:11RDB持久化
Redis的RDB持久化的相关功能主要是在src/rdb.c中实现的.RDB文件是具有一定编码格式的数据文件,因此src/rdb.c中大部分代码都是处理数据格式的问题. 一:RDB文件格式 上图就是一 ...
- 通过游戏学python 3.6 第一季 第三章 实例项目 猜数字游戏--核心代码--猜测次数--随机函数和屏蔽错误代码 可复制直接使用 娱乐 可封装 函数
猜数字游戏--核心代码--猜测次数--随机函数和屏蔽错误代码 #猜数字--核心代码--猜测次数--随机函数和屏蔽错误代码 import random secrst = random.rand ...
- Echarts 的简单使用
http://echarts.baidu.com/index.html 直接用script引入从官网下载的echarts.js文件 官网的文件有几种版本的,按需下载即可,注意精简版的只显示折线.圆柱等 ...
- linux bash算术运算
+, -, *(乘), /(除), **(乘方), %(取模) let var=算术运算符表达式 var=$[算术运算符表达式] var=$((算术运算符表达式)) var=$(expr $ARG1 ...