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 ...
随机推荐
- Shell中取时间格式方法
Shell中取时间格式方法2007-09-13 15:35常用date的显示格式: date +%F //2007-03-06date +%Y%m%d//20070306 date +%T //23: ...
- Ecshop ajax 局部刷新购物车功能
1.比如我们category.dwt 里有 <a href='flow.php'><SPAN id='cart_count_all'>{insert name='cart_in ...
- [转] TreeList 当前节点图标和背景色设置
高原之上原文TreeList 选中节点时图标状态和背景色 // 给TreeList加SelectImage this.treelArea.SelectImageList = imglCustom; / ...
- MFC ListControl用法
http://blog.csdn.net/lovton/article/details/6527208 1.建立一个对象m_LogList 步骤:在对话listcontrol控件右键点击添加变量-&g ...
- UITextView 相关知识点
1.得到UITextView的高度 - (CGRect)contentSizeRectForTextView:(UITextView *)textView { [textView.layoutMana ...
- IOS color 颜色值比较
/生成采样对照颜色(黑色) UIColor* sampleColor = [UIColor colorWithRed:(0/255.0f) green:(0/255.0f) blue:(0/255. ...
- linux常用命令之--用户与用户组管理命令
linux的用户与用户组管理命令 1.用户和群组 groupadd:用于添加新的组群 其命令格式如下: groupadd [-option] 群组名 常用参数: -g GID:指定创建群组的GID(G ...
- pycharm 源文件 编码格式
pycharm 4.5.3 版本 修改项目的编码 按如下操作:菜单 File-Settings-Editor-File Encodings 将IDE Encoding 和 Project Encodi ...
- linux下安装pkg-config时遇到"glib-2.0>=2.16"的错
解决办法 如报错提示所述,加上:--with-internal-glib 即 ./configure --with-internal-glib 参考链接: http://stackoverflow.c ...
- ehcache 的配置
配置:一.在src目录下加入ehcache.xml: <cache name="SimplePageCachingFilter" maxElementsInMemory=&q ...