spring context 继承
- <web-app>
- <display-name>Archetype Created Web Application</display-name>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/applicationContext.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <servlet>
- <servlet-name>example</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/servlet-example.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>example</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
- </web-app>
上面的配置文件定义了 2 个 WebApplicationContext,前一个容器的配置文件是 applicationContext.xml, 后一个容器的配置文件是 servlet-example.xml,前者是后者的 parent。
手动创建父子容器:
- ClassPathXmlApplicationContext appCtx =
- new ClassPathXmlApplicationContext("parent.xml");
- // 指定父容器
- ClassPathXmlApplicationContext childCtx =
- new ClassPathXmlApplicationContext(new String[]{"child.xml"}, appCtx);
现象:子容器可以获得父容器中的 bean,反之不能。
spring context 继承的更多相关文章
- [转载]vs2012中使用Spring.NET报错:Spring.Context.Support.ContextRegistry 的类型初始值设定项引发异常
学习使用Spring.NET中的时候,写了一个Demo,在运行时报了一个错误:Spring.Context.Support.ContextRegistry 的类型初始值设定项引发异常. 重新整理思绪, ...
- Spring context:component-scan中使用context:include-filter和context:exclude-filter
Spring context:component-scan中使用context:include-filter和context:exclude-filter XML: <?xml version= ...
- Spring context:component-scan代替context:annotation-config
Spring context:component-scan代替context:annotation-config XML: <?xml version="1.0" encod ...
- Spring <context:component-scan>标签属性 use-default-filters 以及子标签 include-filter使用说明
Spring <context:component-scan>标签作用有很多,最基本就是 开启包扫描,可以使用@Component.@Service.@Component等注解: 今天要作 ...
- 使用web.xml方式加载Spring时,获取Spring context的两种方式
使用web.xml方式加载Spring时,获取Spring context的两种方式: 1.servlet方式加载时: [web.xml] <servlet> <servlet-na ...
- 【报错】spring整合activeMQ,pom.xml文件缺架包,启动报错:Caused by: java.lang.ClassNotFoundException: org.apache.xbean.spring.context.v2.XBeanNamespaceHandler
spring版本:4.3.13 ActiveMq版本:5.15 ======================================================== spring整合act ...
- Spring Context 你真的懂了吗
今天介绍一下大家常见的一个单词 context 应该怎么去理解,正确的理解它有助于我们学习 spring 以及计算机系统中的其他知识. 1. context 是什么 我们经常在编程中见到 contex ...
- Spring context的refresh函数执行过程分析
今天看了一下Spring Boot的run函数运行过程,发现它调用了Context中的refresh函数.所以先分析一下Spring context的refresh过程,然后再分析Spring boo ...
- Spring中继承配置的注入方法
(1)两个java类.一个父类一个字类 package com.lc.inherit; /* * 这里是父类 */ public class Student { protected String na ...
随机推荐
- Addition Chains
题目描述: 一个与 n 有关的整数加成序列 < a0 , a1 , a2 ...am> 满足一下四个条件: 1.a0=1 2.am=n 3.a0<a1<a2<...< ...
- Windows android appium python3 环境搭建
安装nodejs https://www.cnblogs.com/sea-stream/p/10520624.html java 环境变量配置: https://www.cnblogs.com/sea ...
- ipconfig/all参数解析
本人是在搭建虚拟机时经常需要用到ipconfig/all名称查看宿主机的配置,但是对于该命令下的一些设置经常弄混,所以就花了点时间研究了一下. 参考文献:https://www.cnblogs.com ...
- .NET扩展方法 封装公用方法
定义方法的时候 第一个参数前面加上this 表示这个方法可以被IQueryable类型的对象.出来 调用的时候 只用传第二个参数 第一个参数不用传 第一个参数就是.出当前方法的参数 定义扩展 ...
- 关于在pycharm下提示ModuleNotFoundError: No module named 'XXX' 的一种可能
在pycharm下出现“ModuleNotFoundError: No module named 'XXX' ”提示时, 在网上找大部分的解决方案是重新在pycharm里安装对应的模块,但是这不是我要 ...
- 日志log4cxx 封装、实例讲解、配置文件log4cxx.properties
日志log4cxx 封装.实例讲解.配置文件log4cxx.properties 1. 日志作用 程序运行过程中,需要记录程序中的运行状况,方便排查问题,记录数据.可以根据日志的记录快速定位错误发生的 ...
- 最全的SpringCloud视频教程
史上最全的SpringCloud视频教程 转自:https://blog.csdn.net/itmayeidu/article/details/79426589 史上最全的SpringCloud视频教 ...
- idataway_前端
一半架构,一半标准.---纯属个人意见 ----------------------------------------- 基本的插件:(尽量使用iviews) 1.传输图片. 2.下拉框.日期控件. ...
- 关于Python中的ifelse、while和for循环的简单小结
1.ifelse 1.1首先简单编辑一个关于ifelse的程序: _username = 'yanfeixu' _password = 'wuyifan' username = input(" ...
- ado.net介绍
System.Data:DataTable,DataSet,DataRow,DataColumn,DataRelation,Constraint System.Data.Common(各种数据访问类的 ...