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下面 ...
随机推荐
- xshell连接不了虚拟机处理方法(错误提示:Connection closing...Socket close.Connection closed by foreign host.Disconnected from remote host(localhost) at 08:47:23.)
一.问题描述:xshell连接不了虚拟机,出现错误提示:Connection closing...Socket close.Connection closed by foreign host.Disc ...
- db2,差集
--漏报的数据 FROM A LEFT JOIN A′ ON 交集的条件 WHERE A′.xx IS NULL --多报的数据 FROM A′ LEFT JOIN A ON 交集的条件 WHERE ...
- 创建私有 Gems 源
1.安装依赖 yum install gem -y gem install builder 2.安装.配置nginx的文件列表 添加/etc/nginx/default.d/mirrors.con ...
- 将 Oracle VirtualBox 中运行的虚拟机导入 VMware Fusion、Workstation 或 Player
1.从virtualbox种导出电脑为 .ova格式镜像 要导入 Oracle VirtualBox 中运行的虚拟机,必须将该虚拟机从 VirtualBox 导出到开放虚拟化格式存档(.ova 文件) ...
- hihoCoder#1082 然而沼跃鱼早就看穿了一切
原题地址 字符串匹配+替换 注意替换串和原串长度是不等的,所以替换完还要进行收缩 可以顺带练习一下KMP 代码: #include <iostream> #include <cstr ...
- [luoguP1015] 回文数(模拟 + 高精度?)
传送门 类似高精的操作... 代码 #include <cstdio> #include <cstring> #include <iostream> #define ...
- Linux下汇编语言学习笔记60 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- Linux下汇编语言学习笔记52 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- codeforces Educational Codeforces Round 39 (Rated for Div. 2) D
D. Timetable time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces 628D Magic Numbers
题意: 求在[a,b](a,b不含前导0)中的d−magic数中有多少个是m的倍数. 分析: 计数dp Let's call a number d-magic if digit d appears i ...