近期在项目上,遇到了一个问题。在配置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异常的更多相关文章

  1. SSH applicationContext.xml文件配置

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  2. 关于“Could not open ServletContext resource [/WEB-INF/applicationContext.xml]”解决方案

    问题说明,我在web.xml文件中进行了如下配置 <servlet> <servlet-name>dispatcherServlet</servlet-name> ...

  3. SSH整合,applicationContext.xml中配置hibernate映射文件问题

    今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirec ...

  4. spring的applicationContext.xml配置SessionFactory抛异常

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFa ...

  5. 事务配置在applicationContext.xml文件中不起作用,控制不了异常回滚

    一.博主在学习到整合ssm框架的时候,遇到一个奇葩的问题就是将 事务的控制 ,写在在applicationContext.xml文件中不起作用,在事务控制的方法中,即使出现了异常,但是事务不会回滚的坑 ...

  6. SSH项目练习的时候报错:[applicationContext.xml]: Invocation of init method failed;

    这里是控制台的报错信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name ' ...

  7. [JavaEE] applicationContext.xml配置文件使用合集

    配置实例 – 1 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http ...

  8. applicationContext.xml配置AOP切面编程

    Computer.java package com.wh.aop2; public class Computer { public void play01(){ System.out.println( ...

  9. applicationContext.xml和web.xml的一些配置

    applicationContext.xml <!-- test环境 --> <beans profile="test"> <context:prop ...

随机推荐

  1. nodejs package.json说明

    { "name": "test", //项目名称(必须),由小写英文字母.数字和下划线,不能含空格 "version": "1.0 ...

  2. 垂直对齐:vertical-align属性——使用中注意事项

    1.vertical-align(垂直对齐),只对行内元素和单元格元素有效,例如属性为inline和inline-block的元素以及图片.输入表单等都是行内元素; 2.元素默认的垂直对齐方式为基线对 ...

  3. sudo 授权许可使用的su,也是受限制的su

    sudo 的适用条件: 由于su 对切换到超级权限用户root后,权限的无限制性,所以su并不能担任多个管理员所管理的系统.如果用su 来切换到超级用户来管理系统,也不能明确哪些工作是由哪个管理员进行 ...

  4. LuoguP3690 【模板】Link Cut Tree (动态树) LCT模板

    P3690 [模板]Link Cut Tree (动态树) 题目背景 动态树 题目描述 给定n个点以及每个点的权值,要你处理接下来的m个操作.操作有4种.操作从0到3编号.点从1到n编号. 0:后接两 ...

  5. jsonRPC

    <?php /** * Simple JSON-RPC interface. */ namespace org; class JsonRpc{ protected $host, $port, $ ...

  6. Linux程序包管理初步-rpm的使用

    在Linux系统上,一般而言,对于程序包管理器来说分为三类: debian:dpt,dpkg;             (程序包后缀.deb) rhel:rpm (程序包后缀.rpm) suse:rp ...

  7. Liferay 7:Liferay内部博客地址

    想要了解Liferay最新功能和特性,可以看一看. 非常实用,都是Liferay开发者写的: https://web.liferay.com/zh/community/blogs/all

  8. springcloud的服务提供者与服务消费者

    1.说明 springcloud中由服务消费者调用服务提供者一共有两种方法rest和feign 2.feign (1)使用feign的方式进行服务调,搭建服务提供者. 创建一个web项目(服务提供者) ...

  9. 超干货!Cassandra Java堆外内存排查经历全记录

    背景 最近准备上线cassandra这个产品,同事在做一些小规格ECS(8G)的压测.压测时候比较容易触发OOM Killer,把cassandra进程干掉.问题是8G这个规格我配置的heap(Xmx ...

  10. 搭建单向HTTPS

    //参考网址:https://blog.csdn.net/haolipengzhanshen/article/details/51278262 //打开CMD窗口 cd C:\wamp\bin\apa ...