Spring 框架学习 —— 容器
容器是 Spring 框架的核心。Spring 容器使用 DI(依赖注入)机制管理构成应用的组件(类),所谓 DI,也即是其能够创建相互协作的组件(类)之间的关联(依赖)。
1. 应用上下文(ApplicationContext)
ApplicationContext(应用上下文,org.springframework.context.ApplicationContext 接口)基于 BeanFactory(org.springframework.beans.factory)创建,并提供应用框架级别的服务,比如十分实用的从属性文件解析文本信息以及发布应用事件给感兴趣的监听者。
- AnnotationConfigApplicationContext
- 从配置类(XXConfig.java)中加载
- AnnotationConfigWebApplicationContext
- ClassPathXmlApplicationContext
- 类路径
- FileSystemXmlApplicationContext
- 文件系统路径
- XmlWebApplicationContext
ApplicationContext ctx = new
AnnotationConfigApplicationContext(
xx.xx.xx.KnightConfig.class);
ApplicationContext ctx = new
FileSystemXmlApplicationContext("C:/knigt.xml");
ApplicationContext ctx = new ClassPathXmlApplicationContext("knight.xml");
// class path 类路径下的 knight.xml
// project_name/src/main/java ⇒ 类路径;
// 类路径下的 knight.xml 即为:project_name/src/main/java/resources/knight.xml
应用上下文准备就绪之后(ApplicationContext 对象实例化之后),便可以调用上下文的 getBean 方法从 Spring 容器中获取 bean。
Spring 框架学习 —— 容器的更多相关文章
- Spring框架学习一
Spring框架学习,转自http://blog.csdn.net/lishuangzhe7047/article/details/20740209 Spring框架学习(一) 1.什么是Spring ...
- Spring框架学习1
AnonymouL 兴之所至,心之所安;尽其在我,顺其自然 新随笔 管理 Spring框架学习(一) 阅读目录 一. spring概述 核心容器: Spring 上下文: Spring AOP ...
- Spring框架学习之IOC(二)
Spring框架学习之IOC(二) 接着上一篇的内容,下面开始IOC基于注解装配相关的内容 在 classpath 中扫描组件 <context:component-scan> 特定组件包 ...
- Spring框架学习之IOC(一)
Spring框架学习之IOC(一) 先前粗浅地学过Spring框架,但当时忙于考试及后期实习未将其记录,于是趁着最近还有几天的空闲时间,将其稍微整理一下,以备后期查看. Spring相关知识 spri ...
- Spring框架学习总结(上)
目录 1.Spring的概述 2.Spring的入门(IOC) 3.Spring的工厂类 4.Spring的配置 5.Spring的属性注入 6.Spring的分模块开发的配置 @ 1.Spring的 ...
- Spring框架学习笔记(8)——spring boot+mybatis plus+mysql项目环境搭建
之前写的那篇Spring框架学习笔记(5)--Spring Boot创建与使用,发现有多小细节没有提及,,正好现在又学习了mybatis plus这款框架,打算重新整理一遍,并将细节说清楚 1.通过I ...
- spring框架学习(三)junit单元测试
spring框架学习(三)junit单元测试 单元测试不是头一次听说了,但只是听说从来没有用过.一个模块怎么测试呢,是不是得专门为一单元写一个测试程序,然后将测试单元代码拿过来测试? 我是这么想的.学 ...
- spring 框架学习网站
spring 框架学习网站 NO1 http://www.mkyong.com NO2 https://spring.io/docs/reference
- Spring框架IOC容器和AOP解析 非常 有用
Spring框架IOC容器和AOP解析 主要分析点: 一.Spring开源框架的简介 二.Spring下IOC容器和DI(依赖注入Dependency injection) 三.Spring下面 ...
随机推荐
- uLua-案例学习-API
LuaState.Start()初始化吧 LuaState.AddSearchPath(string fullPath)增加搜索路径,这样在执行lua文件时就不需要输入全路径,类似环境变量path. ...
- Linux学习笔记(一) 文件系统
对于每一个 Linux 学习者来说,了解 Linux 文件系统的结构是十分有必要的 因为在 Linux 中一切皆文件,可以说只有深入了解 Linux 的文件系统,才会对 Linux 有更深刻的理解 L ...
- 4.model 字段
一.字段名 字段名 类型 参数 AutoField(Field) - int自增列, 必须填入参数 primary_key=True BigAutoField(AutoField) - bigint自 ...
- ZOJ 2567 Trade
Trade Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Original ID: 2567 ...
- Jquery根据JSON生成Table
先说下背景 本人属于juqery小白中的极品小白.基本对于JS jquery这些不懂.用到时候基本百度下 拿过来改改OK. 上面这东西让我弄了三天.可能对于其他人来说 一天就搞定了 .看来还真得去学一 ...
- 【ZJOI2017 Round1练习&&BZOJ5353】D7T2 guess(费用流)
题意: 思路: ..]of longint; pre:..,..]of longint; inq:..]of boolean; q:..]of longint; n,m,i,j,ans,tot,sou ...
- Mayor's posters-POJ2528(线段树+离散化)
The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign h ...
- Warm up-HUD4612(树的直径+Tarjin缩点)
http://acm.hdu.edu.cn/showproblem.php?pid=4612 题目大意:求加一条边最小的桥数 先用Tarjin缩点求出一棵树,然后用bfs求出树的直径,树的直径就是加一 ...
- cogs——8. 备用交换机
8. 备用交换机 ★★ 输入文件:gd.in 输出文件:gd.out 简单对比时间限制:1 s 内存限制:128 MB [问题描述] n个城市之间有通讯网络,每个城市都有通讯交换机,直 ...
- Ubuntu 16.04 GNOME添加桌面图标/在桌面上显示图标
GNOME默认不能在桌面上创建文件夹,但是可以通过工具设置:用gnome-tweak-tool设置Nautilus接管桌面即可. 安装: sudo apt-get install gnome-twea ...