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 ...
随机推荐
- 面试题中关于String的常见操作
题目1: 将用户输入的一段话,每个单词的首字母大写, 每个单词之间的空格调整为只有一个,遇到数字,将数字与后一个单词用下划线 "_" 进行连接 题目2:将 i @@ am @@@ ...
- Android application backup
警告 AndroidMenifest中application标签下android:allowBackup="true"时,会警告: Warning:On SDK version 2 ...
- 从flask视角理解angular(三)ORM VS Service
把获取模型数据的任务重构为一个单独的服务,它将提供英雄数据,并把服务在所有需要英雄数据的组件间共享. @Injectable() export class HeroService { getHeroe ...
- MySQL processlist/kill
1.show full processlist 显示MySQL所有正在执行的进程,用于查看当前的MySQL运行情况,避免死锁等导致的异常情况. 主要的列: Id:进程Id User:登录账号 Host ...
- 第 5 章 网络 - 031 - none和host网络的适用场景
none和host网络的适用场景 Docker 安装时会自动在 host 上创建三个网络,用 docker network ls 命令查看: root@ubuntu:~# docker network ...
- Interval 间隔问题
2018-09-07 09:03:14 一.Merge Intervals 问题描述: 问题求解: public List<Interval> merge(List<Interval ...
- oracle.exe 内存占用过大
现象: 明明各个schema 占用的磁盘空间都不大. oracle.exe 却占用了差不多 3G 的内存. 解决: 查了google,各种英文关键字没有找到原因. 最后,中文检索到了. https:/ ...
- linux: 安装jdk(java)
作为Java开发人员,在Linux下安装一些开发工具是必备技能,本文以安装jdk为例,详细记录了每一步的操作命令,以供参考. 0.下载jdk8 登录网址:http://www.oracle.com/t ...
- CentOS上安装seafile
一.安装python2.7.14(CentOS7上python默认版本是Python 2.7.5 ,不需要安装)1.安装依赖包[root@web01 ~]# yum -y install zlib z ...
- 【转载】MacOS下IntelliJ IDEA关联JDK1.8源码
原文地址: MacOS下IntelliJ IDEA关联JDK1.8源码 1 打开jdk设置,找到具体添加的地方 2 找到自己jdk的源码位置替换掉 3 如果没有源码或者源码没有下载解压,自己下载解压, ...