使用Spring动态加载配置文件
2018-01-23 10:21
501 查看
在web.xml中配置
<!--配置spring全局参数 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationcontext.xml</param-value> </context-param> <!--配置监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
调用时通过以下方式获取ApplicationContext对象
ApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
相关文章推荐
- spring中动态加载配置文件
- Spring中使用classpath加载配置文件浅析
- Spring中使用classpath加载配置文件浅析
- spring-自动加载配置文件\使用属性文件注入
- Spring动态加载配置文件
- Spring中使用classpath加载配置文件浅析 2
- Spring动态加载数据库配置文件
- Controller使用注解@Value加载配置文件 --SpringMVC
- 使用import简化spring的配置 spring import 标签的解析 使用import或加载spring配置时,报错误There is no ID/IDREF 多个Spring配置文件import resource路径配置
- Spring中使用classpath加载配置文件浅析[转]
- Spring使用环境变量控制配置文件加载
- Spring中使用classpath加载配置文件浅析
- 参数配置文件properties--使用spring加载和简化读取
- Java天地 学习探讨Java Spring中使用classpath加载配置文件浅析
- Spring中使用classpath加载配置文件浅析
- spring-自动加载配置文件\使用属性文件注入
- 使用Spring中的ClassPathXmlApplicationContext加载配置文件
- Spring中使用classpath加载配置文件浅析
- Spring使用环境变量控制配置文件加载
- Spring中使用classpath加载配置文件浅析