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 ...
随机推荐
- Scrapy下载图片及自定义分类下载路径
配置下载图片的流程如下 在items中定义两个属性,image_urls 和images .image_urls是用来存储需要下载的图片url链接,列表类型: 当文件下载完成后会把相关下载信息存入im ...
- java 遍历
LinkedList倒序遍历 public List<Integer> getNewsFeed(int userId) { List<Integer> res = new Ar ...
- Hibernate-概述-搭建-测试-配置详解
一 hibernate概述 1.1 框架是什么 1.框架是用来提高开发效率的 2.封装了好了一些功能.我们需要使用这些功能时,调用即可.不需要再手动实现. 3.所以框架可以理解成是一个半成品的项目.只 ...
- C++ base64 opencv Mat 转换
static std::string base64Decode(const char* Data, int DataByte) { //解码表 const char DecodeTable[] = { ...
- vue之this.$route.params和this.$route.query的区别
1.this.$route.query的使用 A.传参数: this.$router.push({ path: '/monitor', query:{ ...
- Django项目:CRM(客户关系管理系统)--28--20PerfectCRM实现King_admin数据修改美化
{#table_change.html#} {## ————————19PerfectCRM实现King_admin数据修改————————#} {#{% extends "king_mas ...
- vue组件与路由的使用步骤
router:根据不同的地址跳转到不同的页面一.vue-router的使用 1.下载路由模块 npm vue-router --save 2.在router.js中 先引入路由 imp ...
- Http中GET和POST请求的区别
https://mp.weixin.qq.com/s/_oLnkDQn3TE7XdFWCT5Img GET请求 GET /books/?sex=man&name=Professional HT ...
- 各NoSQL数据库管理系统与模型比较
提供:ZStack云计算 内容简介 NoSQL数据库的存在意义在于提供传统关系数据库管理系统所不具备的特定功能.无论是负责承载简单的键-值对存储以实现短期缓存,抑或是处理传统数据库及结构化查询语言(简 ...
- Leetcode47. Permutations II全排列2
给定一个可包含重复数字的序列,返回所有不重复的全排列. 示例: 输入: [1,1,2] 输出: [ [1,1,2], [1,2,1], [2,1,1] ] 在全排列1题目的基础上先排序,目的是把相同的 ...