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 ...
随机推荐
- django 应用中获取访问者ip地址
通常访问者的IP就在其中,所以我们可以用下列方法获取用户的真实IP: #X-Forwarded-For:简称XFF头,它代表客户端,也就是HTTP的请求端真实的IP,只有在通过了HTTP 代理或者负载 ...
- Python安装常见问题:ModuleNotFoundError: No module named '_ctypes' 解决办法
一般位于3.7以上版本编译安装时出错 缺少依赖包libffi-devel 在安装3.7以上版本时,需要一个新的libffi-devel包做依赖 解决方法: yum install libffi-dev ...
- python 下载地址
https://www.python.org/ftp/python/
- tensorflow学习笔记一------下载安装,配置环境(基于ubuntu16.04 pycharm)
一,安装TensorFlow 安装所有必备工具 sudo apt-get install python-pip python-dev python-virtualenv 安装TensorFlow su ...
- HDU 1241 连通块问题(DFS入门题)
Input The input file contains one or more grids. Each grid begins with a line containing m and n, th ...
- DAY3 数据类型与运算符
一.注释 代码注释分单行和多行注释, 单行注释用#,多行注释可以用三对双引号""" """ 注释用于解释某一行代码的作用,增加代码的可读性 ...
- Java定时器的三种实现方式
一.普通thread /** * 普通thread * 这是最常见的,创建一个thread,然后让它在while循环里一直运行着, * 通过sleep方法来达到定时任务的效果.这样可以快速简单的实现, ...
- Spring Boot设置值:分别用@ConfigurationProperties和@Value给属性设值及其区别
@ConfigurationProperties给属性映射值编写JavaBean/** 将配置文件application.properties中配置的每一个属性值映射到当前类的属性中:* @Confi ...
- Amaze UI——slider的参数说明
<script type="text/javascript"> $(function(){ $('.am-slider').flexslider({ playAfter ...
- Binomial Coefficient(二项式系数)
In mathematics, any of the positive integers that occurs as a coefficient in the binomial theorem is ...