Spring applicationContext.xml 文件 路径配置 (2)
2017-05-02 14:46
661 查看
Spring配置文件详解 - applicationContext.xml文件路径
spring的配置文件applicationContext.xml的默认地址在WEB-INF下,只要在web.xml中加入代码org.springframework.web.context.ContextLoaderListenerspring就会被自动加载但在实际的开发过程中,我们可能需要调整applicationContext.xml的位置,以使程序结构更加的清晰。在web.xml中,配置Spring配置文件的代码如下:
contextConfigLocation这里写路劲根据Spring框架的API描述,有以下四种方法配置applicationContext.xml文件路径
1. /WEB-INF/applicationContext.xml 2. com/config/applicationContext.xml 3. file:C:/javacode/springdemo/com/config/applicationContext.xml 4. 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.xml2、Spring配置文件在WEB-INF下的某个文件夹下,比如config下,可以这样配置
contextConfigLocation
WEB-INF/config/applicationContext.xml3、Spring配置文件在src下面,可以这样配置
conte96c2xtConfigLocation
WEB-INF/classes/applicationContext.xml或者
contextConfigLocation
classpath:applicationContext.xml4、Spring配置文件在src下的某个包里,比如com.config,可以这样配置
contextConfigLocation
WEB-INF/classes/com/config/applicationContext.xml或者
contextConfigLocation
classpath:com/config/applicationContext.xml
相关文章推荐
- Spring配置文件详解 - applicationContext.xml文件路径
- applicationContext.xml文件中怎么配置struts2和spring配置文件的加载路径
- Spring配置文件详解 - applicationContext.xml文件路径
- Spring配置文件详解 - applicationContext.xml文件路径
- Spring添加事物支持 applicationContext.xml配置文件
- 详解Spring的applicationContext.xml配置文件
- 在Spring的 applicationContext.xml文件中配置数据源
- 一个典型的Spring的applicationcontext.xml配置文件
- Spring的配置文件,可以用applicationContext.xml+applicationContext.properties
- Hibernate SQL方言 (hibernate.dialect) Spring配置文件applicationContext.xml
- Spring的配置文件applicationContext.xml中的 <context:component-scan base-package="com.orm" />
- Spring 配置文件applicationContext.xml的切割原则
- Spring的applicationContext.xml中配置映射文件
- spring+hibernate 配置文件(applicationContext.xml)实例
- Hibernate与Spring整合,配置文件applicationContext.xml
- Spring配置文件总结-applicationContext.xml
- spring+hibernate applicationContext.xml配置文件写法
- Spring配置文件applicationContext.xml(1)基本配置
- Hibernate SQL方言 (hibernate.dialect) Spring配置文件applicationContext.xml
- 请慎用spring-ClassPathXmlApplicationContext手动加载spring配置文件