公司的考勤系统程序,有5个spring配置文件:bean-edu.xml,bean-pub.xml,db-edu.xml,db-pub.xml,timer-system.xml,均放置于src目录下,在web.xml中配置这些文件的代码如下:

  1. <context-param>
  2. <param-name>contextConfigLocation</param-name>
  3. <param-value>classpath:/db-pub.xml,
  4. classpath:db-edu.xml,
  5. classpath:bean*.xml,
  6. classpath*:timer-system.xml
  7. </param-value>
  8. </context-param>

注意:部署程序启动tomcat之后,log4j显示出  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [db-pub.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [db-edu.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from file [E:\apache-tomcat-6.0.33-windows-x86\apache-tomcat-6.0.33\webapps\DigitalCampus\WEB-INF\classes\bean-edu.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from file [E:\apache-tomcat-6.0.33-windows-x86\apache-tomcat-6.0.33\webapps\DigitalCampus\WEB-INF\classes\bean-pub.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  -  Loading XML bean definitions from URL [file:/E:/apache-tomcat-6.0.33-windows-x86/apache-tomcat-6.0.33/webapps/DigitalCampus/WEB-INF/classes/timer-system.xml]

  1. <context-param>
  2. <param-name>contextConfigLocation</param-name>
  3. <param-value>classpath:/db-pub.xml,
  4. classpath:db-edu.xml,
  5. classpath*:bean*.xml,
  6. /WEB-INF/classes/timer-system.xml
  7. <!--  classpath*:timer-system.xml-->
  8. </param-value>
  9. </context-param>

[main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [db-pub.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [db-edu.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from file [E:\apache-tomcat-6.0.33-windows-x86\apache-tomcat-6.0.33\webapps\DigitalCampus\WEB-INF\classes\bean-edu.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from file [E:\apache-tomcat-6.0.33-windows-x86\apache-tomcat-6.0.33\webapps\DigitalCampus\WEB-INF\classes\bean-pub.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/timer-system.xml] 
根据以上两个例子:  1 classpath和classpath*的区别是:前者from class path resource,后者from URL。classpath:只会到你的class路径中查找找文件;  classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找.  2 带不带有/,没有区别。  3 bean*.xml查找的是以bean开头的配置文件,from file  4 classpath*:bean*.xml 为from file.  5   /WEB-INF/classes/timer-system.xml 为from ServletContext resource。

另外:  "**/" 表示的是任意目录;  "**/applicationContext-*.xml" 表示任意目录下的以"applicationContext-"开头的XML文件。  程序部署到tomcat后,src目录下的配置文件会和class文件一样,自动copy到应用的 WEB-INF/classes目录下

web.xml中通过contextConfigLocation的读取spring的配置文件的更多相关文章

  1. 【转】web.xml中的contextConfigLocation在spring中的作用

    一.spring中如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocation参数,Spring会使用这个参数去加载所有逗号分隔的xml文件,如果没有这个参数,sp ...

  2. (转)web.xml中的contextConfigLocation在spring中的作用

    (转)web.xml中的contextConfigLocation在spring中的作用   一.Spring如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocat ...

  3. web.xml中的contextConfigLocation在spring中的作用

    在web.xml中通过contextConfigLocation配置spring, contextConfigLocation参数定义了要装入的 Spring 配置文件.默认会去/WEB-INF/下加 ...

  4. web.xml中的contextConfigLocation的作用

    在web.xml中通过contextConfigLocation配置spring,contextConfigLocation 参数定义了要装入的 Spring 配置文件. 如果想装入多个配置文件,可以 ...

  5. 在web.xml中通过contextConfigLocation配置spring

    <context-param>         <param-name>contextConfigLocation</param-name>         < ...

  6. web.xml中contextConfigLocation的作用(转)

    原文地址:http://blog.csdn.net/zhangliao613/article/details/6289114 原文格式较乱,此处略作整理.内容未变. 在web.xml中使用contex ...

  7. spring 和springmvc 在 web.xml中的配置

    (1)问题:如何在Web项目中配置Spring的IoC容器? 答:如果需要在Web项目中使用Spring的IoC容器,可以在Web项目配置文件web.xml中做出如下配置: <!-- Sprin ...

  8. 使用Spring时web.xml中的配置

    使用Spring时web.xml中的配置: <?xml version="1.0" encoding="UTF-8"?> <web-app x ...

  9. web.xml中配置Spring中applicationContext.xml的方式

    2011-11-08 16:29 web.xml中配置Spring中applicationContext.xml的方式 使用web.xml方式加载Spring时,获取Spring applicatio ...

随机推荐

  1. PTEST 渗透测试标准

    1:前期交互阶段 在前期交互(Pre-Engagement Interaction)阶段,渗透测试团队与客户组织进行交互讨论,最重要的是确定渗透测试的范围.目标.限制条件以及服务合同细节.该阶段通常涉 ...

  2. POJ1144 tarjan+网络中割点与割边的数量

    题目链接:http://poj.org/problem?id=1144 割点与割边的数量我们可以通过tarjan的思想从一个点开始对其余点进行访问.访问的顺序构成一棵dfs树,其中根节点到任何一个结点 ...

  3. 洛谷 P5176 公约数 题解

    原题链接 我天哪 大大的庆祝一下: 数论黑题 \(T1\) 达成! 激动地不行 记住套路:乱推 \(\gcd\),欧拉筛模板,然后乱换元,乱换式子,完了整除分块,欧拉筛和前缀和就解决了! \[\sum ...

  4. SpringBoot项目中应用Jedis和一些常见配置

    优雅的使用Jedis Redis的Java客户端有很多,Jedis是其中使用比较广泛和性能比较稳定的一个.并且其API和RedisAPI命名风格类似,推荐大家使用 在项目中引入Jedis 可以通过Ma ...

  5. Android进阶AIDL使用自定义类型

    原文首发于微信公众号:jzman-blog,欢迎关注交流! 上篇文章中主要介绍从 AIDL 的使用方式以及 Android 开发中不同进程之间的通信,遗留的问题是如何在 AIDL 中使用自定义类型,具 ...

  6. JavaScript/JQuery对图片放大或缩小失效

    将图片的父元素的宽度和高度也设置后,问题解决.Got it!

  7. 1642: 【USACO】Payback(还债)

    1642: [USACO]Payback(还债) 时间限制: 1 Sec 内存限制: 64 MB 提交: 190 解决: 95 [提交] [状态] [讨论版] [命题人:外部导入] 题目描述 &quo ...

  8. DAO,Service,Controler的简介

    DAO层: DAO层叫数据访问层,全称为data access object,属于一种比较底层,比较基础的操作,具体到对于某个表的增删改查,也就是说某个DAO一定是和数据库的某一张表一一对应的,其中封 ...

  9. Oracle数据库表和表列讲解

    如果将数据库比作一个存储东西的储物柜,表就像是储物柜上的各个抽屉,每个抽屉分门别类地存放了各种数据,在设计和规划数据库时,表的定义和规划往往相当重要,良好的表设计决定了程序人员编写程序的便利性与数据库 ...

  10. STM32F103ZET6的基本定时器

    1.定时器的分类 STM32F103ZET6总共有8个定时器,它们是:TIM1~TIM8.STM32的定时器分为基本定时器.通用定时器和高等定时器. TIM6.TIM7是基本定时器.基本定时器是只能向 ...