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 ...
随机推荐
- 【Java】【事件处理机制】
import javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.Actio ...
- _spellmod_leech_aura
comment 备注 aura 光环ID,玩家有这个光环时候造成的伤害会转化成吸血效果 chance 每次伤害转化成吸血效果的几率 type 吸血的类型,数据库枚举类型,可以直接选取 base ...
- JS实现 进度条 不用控件
demo1 <html> <head> <title>进度条</title> <style type="text/css"&g ...
- lattice 作图 举例
library(lattice) Depth <- equal.count(quakes$depth, number=8, overlap=.1)xyplot(lat ~ long | Dept ...
- 转载 R语言颜色基础设置
原文链接:http://www.biostatistic.net/thread-5065-1-1.html R语言在画图形的时候,经常遇到颜色设定问题,用户可以根据color.rgb值和hsv值来设定 ...
- macOS下Hive 2.x的安装与配置
1 简介 Hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供简单的[SQL]查询功能,可以将SQL语句转换为MapReduce任务进行运行.其优点是学习成本 ...
- 关于JS历史
js由来 95年那时,绝大多数因特网用户都使用速度仅为28.8kbit/s 的“猫”(调制解调器)上网,但网页的大小和复杂性却不断增加.为完成简单的表单验证而频繁地与服务器交换数据只 ...
- Codeforces 1079 E - The Unbearable Lightness of Weights
E - The Unbearable Lightness of Weights 思路: 分组背包dp 每组最多只能选一个 一些优化可以快很多 代码: #pragma GCC optimize(2) # ...
- 日常英语---九、冒险岛link技能导读
日常英语---九.冒险岛link技能导读 一.总结 一句话总结:选最值得练的link技能列上来,先熟悉一部分,没必要一开始就全部弄懂,这样压力太大,可以先熟悉比较有意义的一部分啊 学以致用-还不如说成 ...
- 新C# 操作Excel属性
C# 操作Excel属性 数字(Range.NumberFormatlocal 属性) 常规:Range.NumberFormatlocal = "G/通用格式" 数值:Range ...