Spring applicationContext.xml 文件 路径配置 (2)
来源:互联网 发布:vb.net 读取资源文件 编辑:程序博客网 时间:2024/06/06 00:54
Spring配置文件详解 - applicationContext.xml文件路径
spring的配置文件applicationContext.xml的默认地址在WEB-INF下,只要在web.xml中加入代码
org.springframework.web.context.ContextLoaderListener
spring就会被自动加载
但在实际的开发过程中,我们可能需要调整applicationContext.xml的位置,以使程序结构更加的清晰。在web.xml中,配置Spring配置文件的代码如下:
contextConfigLocation这里写路劲
根据Spring框架的API描述,有以下四种方法配置applicationContext.xml文件路径
1. /WEB-INF/applicationContext.xml2. com/config/applicationContext.xml3. file:C:/javacode/springdemo/com/config/applicationContext.xml4. classpath:com/config/applicationContext.xml
注:以上路径只是举例,具体使用还是要针对真是项目的,做编程的这点举一反三能力还是有的吧
开发过程中,如果spring的配置文件applicationContext.xml未加载的话,一般回报这样的错误 Could not open ServletContext resource [/WEB-INF/applicationContext.xml] 下面就有我为大家举例自定义applicationContext.xml路径的常见的方法。
1、Spring配置文件在WEB-INF下面
这种情况你可以不去管他,不进行配置,因为spring会默认去加载,如果一定要配置呢,可以这样
contextConfigLocation
WEB-INF/applicationContext.xml
2、Spring配置文件在WEB-INF下的某个文件夹下,比如config下,可以这样配置
contextConfigLocation
WEB-INF/config/applicationContext.xml
3、Spring配置文件在src下面,可以这样配置
contextConfigLocation
WEB-INF/classes/applicationContext.xml
或者
contextConfigLocation
classpath:applicationContext.xml
4、Spring配置文件在src下的某个包里,比如com.config,可以这样配置
contextConfigLocation
WEB-INF/classes/com/config/applicationContext.xml
或者
contextConfigLocation
classpath:com/config/applicationContext.xml
0 0
- Spring applicationContext.xml 文件 路径配置 (2)
- Spring applicationContext.xml 路径配置(1)
- Spring-applicationContext.xml路径配置
- Spring配置文件详解 - applicationContext.xml文件路径
- Spring配置文件详解 - applicationContext.xml文件路径
- Spring配置文件详解 - applicationContext.xml文件路径
- Spring配置文件详解 - applicationContext.xml文件路径
- Spring配置文件详解 - applicationContext.xml文件路径
- applicationContext.xml文件中怎么配置struts2和spring配置文件的加载路径
- Spring beans.xml(applicationContext.xml) 配置
- spring applicationContext.xml配置
- spring applicationContext.xml配置
- 配置applicationcontext.xml文件
- applicationContext.xml文件配置
- Spring中的applicationContext.xml配置错误2
- Spring配置文件(applicationContext.xml如何配置)
- applicationContext.xml文件配置小结(1)
- Spring源码学习--Spring配置解析文件ApplicationContext.xml(一)
- Java面向对象设计模式(一)——工厂方法模式
- H5 调用摄像头
- C语言学习历程——编程练习2——08
- SpringMVC常用获取传递参数的方法
- 算法---直接插入排序法
- Spring applicationContext.xml 文件 路径配置 (2)
- Map的keySet方法(转载)
- 南阳理工acm 18 The Triangle
- 开源中国android客户端源码分析-学习笔记1
- 图片加载框架的选择问题(Fresco,Glide,Picasso,UIL)
- 清除浮动的代码
- Oracle 创建Package Procedure Function
- 性能测试(硬件性能指标汇总)
- Android架构师之路以健身圈为例1:概述