applicationContext.xml存放的位置
- web.xml中classpath:和classpath*: 有什么区别?
- classpath:只会到你的class路径中查找找文件;
- classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找.
- 存放位置:
- 1:src下面
- 需要在web.xml中定义如下:
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:applicationContext.xml</param-value>
- < /context-param>
- 2:WEB-INF下面
- 需要在web.xml中定义如下:
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>WEB-INF/applicationContext*.xml</param-value>
- < /context-param>
- web.xml 通过contextConfigLocation配置spring 的方式
- SSI框架配置文件路径问题:
- struts2的 1个+N个 路径:src+src(可配置) 名称: struts.xml + N
- spring 的 1个 路径: src 名称: applicationContext.xml
- ibatis 的 1个+N个 路径: src+src(可配置) 名称: SqlMapConfig.xml + N
- 部署到tomcat后,src目录下的配置文件会和class文件一样,自动copy到应用的 classes目录下
- spring的 配置文件在启动时,加载的是web-info目录下的applicationContext.xml,
- 运行时使用的是web-info/classes目录下的applicationContext.xml。
- 配置web.xml使这2个路径一致:
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
- < /context-param>
- 多个配置文件的加载
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>
- classpath*:conf/spring/applicationContext_core*.xml,
- classpath*:conf/spring/applicationContext_dict*.xml,
- classpath*:conf/spring/applicationContext_hibernate.xml,
- classpath*:conf/spring/applicationContext_staff*.xml,
- classpath*:conf/spring/applicationContext_security.xml
- classpath*:conf/spring/applicationContext_modules*.xml
- classpath*:conf/spring/applicationContext_cti*.xml
- classpath*:conf/spring/applicationContext_apm*.xml
- </param-value>
- </context-param>
- contextConfigLocation 参数定义了要装入的 Spring 配置文件。
- 首先与Spring相关的配置文件必须要以"applicationContext-"开头,要符合约定优于配置的思想,这样在效率上和出错率上都要好很多。
- 还有最好把所有Spring配置文件都放在一个统一的目录下,如果项目大了还可以在该目录下分模块建目录。这样程序看起来不会很乱。
- 在web.xml中的配置如下:
- Xml代码
- <context-param>
- < param-name>contextConfigLocation</param-name>
- < param-value>classpath*:**/applicationContext-*.xml</param-value>
- < /context-param>
- "**/"表示的是任意目录;
- "**/applicationContext-*.xml"表示任意目录下的以"applicationContext-"开头的XML文件。
- 你自己可以根据需要修改。最好把所有Spring配置文件都放在一个统一的目录下,如:
- <!-- Spring 的配置 -->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:/spring/applicationContext-*.xml</param-value>
- < /context-param>
applicationContext.xml存放的位置的更多相关文章
- applicationContext.xml的文件位置就可以有两种默认实现
ContextLoaderListener的作用就是启动Web容器时,自动装配ApplicationContext的配置信息.因为它实现了ServletContextListener这个接口,在web ...
- applicationContext.xml文件放置位置不同而导致的jUnit测试的时候路径的不同
如果applicationContext.xml文件放置在src下面的的时候使用jUint测试的时候编写的路径应该是这样的: @Test public void testFindByPage() { ...
- 转:applicationContext.xml文件放置位置不同而导致的jUnit测试的时候路径的不同
如果applicationContext.xml文件放置在src下面的的时候使用jUint测试的时候编写的路径应该是这样的: @Test public void saveTest() { Applic ...
- Spring中,applicationContext.xml 配置文件在web.xml中的配置详解
一.首先写一下代码结构. 二.再看web.xml中的配置情况. <?xml version="1.0" encoding="UTF-8"?> < ...
- spring-mvc.xml 和 application-context.xml的区别
转自:https://www.cnblogs.com/binlin1987/p/7053016.html application-context.xml是全局的,应用于多个serverlet,配合li ...
- 【Spring】如何配置多个applicationContext.xml文件
在web.xml中通过contextConfigLocation配置spring 开发Java Web程序,使用ssh架构时,默认情况下,Spring的配置文件applicationContext.x ...
- applicationContext.xml 配置文件的存放位置
eb.xml中classpath:和classpath*: 有什么区别? classpath:只会到你的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件中 ...
- [JavaEE] applicationContext.xml配置文件使用合集
配置实例 – 1 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http ...
- applicationContext.xml中的使用${}是代表什么意思?
在applicationContext.xml文件中,使用 ${xxx} 表示的是:调用某个变量,该变量的名称就是{xxx}里面的"xxx". 例如:在applicationC ...
随机推荐
- 物联网操作系统HelloX V1.78测试版正式发布
经过HelloX开发团队近四个月的努力,在HelloX V1.77版本基础上,增加许多功能特性,并对V1.77版本的一些特性进行了进一步优化之后,正式形成HelloX V1.78测试版本,经相对充分的 ...
- Java [Leetcode 290]Word Pattern
题目描述: Given a pattern and a string str, find if str follows the same pattern. Here follow means a fu ...
- LeetCode: divideInteger
Title: Divide two integers without using multiplication, division and mod operator. If it is overflo ...
- 【转】pdf 中如何把几页缩小成一页打印
我用的是Foxit PDF Reader,可以这样设置:文件-打印-打印处理下的页面排列选择“在每张纸上放置多页”-选择每页版数即可. 如果你用的是Adobe Reader,也可以自己找一下,看是否有 ...
- ECSHOP v2.5数据库字典
ECSHOP v2.5 数据库字典 ECSHOP R&D Team 2007年4月16日 商品相关表 商品分类表 category 此表用来维护商品分类信息 字段名 字段描述 字段类型 默认值 ...
- jdbc:oracle:thin:@192.168.3.98:1521:orcl(详解)
整理自互联网 一. jdbc:oracle:thin:@192.168.3.98:1521:orcljdbc:表示采用jdbc方式连接数据库oracle:表示连接的是oracle数据库thin:表示连 ...
- POJ 2253 Difference of Clustering
题意:给出一堆点,求从起点到终点的所有通路中相邻点的距离的最大值的最小值.(意思就是自己百度吧……) 解法:用相邻点的最大值作为权值代替路径的距离跑最短路或者最小生成树.然后我写了一个我以为是优化过的 ...
- equals(),hashcode()方法详解
Java中的equals方法和hashCode方法是Object中的,所以每个对象都是有这两个方法的,有时候我们需要实现特定需求,可能要重写这两个方法,今天就来介绍一些这两个方法的作用. equals ...
- delphi7在win7系统如何安装spcomm控件
1.先准备好串口控件SPCOMM,例如把它放在F盘的工具安装文件夹下,等一下加载时需要用到. 2.打开delphi7软件. 3.按下上面的Component>Install Component ...
- C++实现网格水印之调试笔记(三)—— 初有结果
错误: error C2338: THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD 这种错误 ...