Spring 之Srping IOC运行时序图

Windows 11安装realtek audio control Windows 11安装realtek audio control,解决无法链接RPC问题 阅读详情

加载XML文件——创建IOC容器时序图

源码理解

首先需要找到入口。IOC容器初始化运行的入口。

回顾

什么是SpringIOC

IOC(Inversion Of Control)控制反转,所谓控制反转,就是把我们代码中需要实现的对象的创建、依赖。反转给容器来实现。同时需要一种描述让容器知道需要创建的对象和对象之间的关系。即配置文件。

寻找源码入口

1.关于BeanFactory

BeanFactory:顶层接口类,定义了IOC容器的基本规范。
三个重要子类:ListableBeanFactory、HierarchicalBeanFactory 和 AutowireCapableBeanFactory
最终的默认实现类:DefaultListableBeanFactory
Spring内部在操作过程中对象的传递和转化过程中,有这各自的职能。如ListableBeanFactory接口,表示可初始化列表Bean

根据时序图来解析

如何找到入口

通过对Spring的使用以及初步的认识,我们知道Spring的初始化是从DispatcherServlet开始的,我们可以发现Spring中有许多init开头的方法,顾名思义,这些方法就是为Spring初始化做准备的。通过其继承关系,我们可以在其父类中找到最初的init()方法。

我们在HttpServletBean中可以发现有一个名为initServletBean()的方法。

注意圈红的代码,结合我们在项目中使用Spring的时候控制台打出的日志。

没有任何问题,我们找到入口了。(持续更新中,,,)

---------------------------------------------------2019-06-05---------------------------------------------------------------------------------------

入口已经找到,接下来慢慢抽丝剥茧揭开神秘的IOC容器的“面纱”

在initservletBean方法中,我们可以发现调用了initWebApplicationContext方法,我们来看这个方法

有一个方法叫作configureAndRefreshWebApplicationContext

在此方法中调用了refresh()方法,我们可以简单理解为,在Spring启动过程中会调用refresh方法。这个时候让我们在这个方法上多加点注意力。

IOC容器初始化的流程

容器启动的过程大概可以概括为三个步骤定位、加载和注册。即定位我们的配置文件,加载配置文件和根据配置文件进行注册

以ApplicationContext为例,我们可以在main中启动对xml文件的加载。以此来帮助我们去认识IOC容器。

通过对其构造方法的跟踪,我们发现调用了refresh()方法,也就是我们时序图的起点。通过setConfigLocations方法我们也可以发现,配置文件通过字符串数组的形式进行传递。这里可以作为我们学习IOC容器的起点,即,定位配置文件。

根据时序图我们可以一步一步去学习认识IOC容器的初始化过程。

2019-06-08:更为详细的IOC运行时序图

如何使用 Python 爬取 58 同城招聘信息 职位名称:招聘的岗位名称,如“前端开发”、“数据分析师”等。公司名称:招聘公司的名称。薪资待遇:职位的薪资范围,通常以“面议”、“10k-20k”这样的形式表示。工作地点:公司所在的城市及具体地址。公司福利:例如五险一金、带薪年假、绩效奖金等。发布时间:职位信息的发布时间。一个典型的招聘页面 URL 格式通常如下:在这个页面上,职位信息会分页展示,爬虫需要模拟翻页,获取多个页面的招聘信息。 阅读详情

相关推荐

mfcc总结,这个mel三角滤波器分组到底是如何起作用的呢?

先看fft频谱图(这是4096字节取样fft计算,横轴频率是从0到512,后边意义不大,未取,纵轴是振幅),那些我随便画的蓝色线,你有什么联想?: 再看,这绿色线,是否有一种上升后,便逐渐式微的感觉,都是三角形的,这或许也是mel当初和绝大多数人看到的: 如果在振幅上加上一条限制的黑线(振幅门槛限制),黑色线以下很多频率就没有意义了,你看,有用的频率连一半(512/2=256)都占不到...

ganggangwawa的博客 9908

Spring之Spring IoC时序图

Spring IoC加载时序图解析时序图大纲预览 时序图大纲预览

weixin_44692700的博客 1259

BODAS说明书的中文版与相关资料总结

花了三天时间配了控制器的接线口,找了软件安装的一套东西。 又花了一周时间零零散散在网上只找到关于控制器少得可怜的资料: 1.力士乐控制器RC6系列介绍 2.力士乐控制器手册不完整版 3.RC6-9程序下载 力士乐配套的只有德语和英语两版,人工翻译专业文件的价格太惊人,决定自己写一版方便大家。有不正之处欢迎指出。 For these controllers, in the event of an...

我的技术日常 6495

21.手绘Spring IOC运行时序图

1.再谈IOC与 DI IOC(lnversion of Control)控制反转:所谓控制反转,就是把原先我们代码里面需要实现的对象创 建、依赖的代码,反转给容器来帮忙实现。那么必然的我们需要创建一个容器,同时需要一种描述来让 容器知道需要创建的对象与对象的关系。这个描述最具体表现就是我们所看到的配置文件。 DI(Dependency Injection)依赖注入:就是指对象是被动接受依赖类而不...

编程之心的博客 727

S型速度曲线C程序实现

S型速度曲线C语言程序实现 前言 S型曲线相较于梯形速度曲线具有运行更加平稳的特点,S型曲线共有八种运行情况,感兴趣可以查阅相关文献 代码段 #include <stdio.h> #include <math.h> #define FP64 double int main(void) { /**************************** 定义相关变量(需要映射到PLC寄存器才能进行监控) ***********************/ FP6

LSX312441548的博客 8392

3GPP LTE/NR信道模型

CDL(Clustered Delay Line):簇延迟线模型,包括CDL-A、CDL-B、CDL-C三个用于NLOS的信道模型,以及CDL-D、CDL-E两个用于LOS的信道模型。

LinkEverything的博客 1万+

Spring中IOC详解

一、IOC的原型 IOC ----控制反转 比如我们有一个功能是获取用户数据,我们使用Dao层实现这个功能,再在Service层调用这个功能。但是我们每增加一个接口,比如获取mysql中的数据,就要修改原来的代码,如果再增加一个新的接口,又需要去service实现类中修改对应的实现。 解决方法 用户实际调用的是业务层,dao层他们不需要接触 UserServiceImpl userService = new UserServiceImpl(); userSe

qq_41359998的博客 1万+

【逆向实战】Unity游戏资源提取与解密全攻略:从AssetBundle到libil2cpp.so的破解技巧

本文详细介绍了Unity游戏资源提取与解密的完整流程,涵盖从AssetBundle到libil2cpp.so的破解技巧。通过AssetStudio和Il2CppDumper等工具,读者可以学习如何提取未加密资源、处理加密文件,并掌握动态dump技术。文章还提供了自动化脚本编写和常见问题解决方案,帮助逆向工程爱好者高效完成资源提取任务。

weixin_29012765的博客 1048

Spring IoC详解

Spring 是一个开源的Java框架,它提供了丰富的功能和组件,用于简化企业级应用程序的开发。Spring 框架提供了依赖注入、面向切面编程、事务管理、数据访问等功能,是一个全面的企业应用开发解决方案。Spring MVC 是 Spring 框架中的一个模块,即Spring功能的一部分,用于构建 Web 应用程序的 MVC(Model-View-Controller)架构。Spring MVC 提供了基于注解的方式来定义控制器、处理请求和渲染视图,使得开发 Web 应用程序更加简单和灵活。

2303_78892316的博客 5008

39-Halcon-- fit_primitives_object_model_3d函数功能(从3D数据中提取几何基元)

Halcon算子fit_primitives_object_model_3d工业应用精要 该算子专为3D几何特征提取设计,支持平面、球体、圆柱等基元拟合。核心优势: 参数化输出:返回几何元素的数学参数(如平面方程、球心半径) 智能控制:通过max_dist、min_size等参数调节拟合精度 工业场景适配:针对薄壁件、孔系等提供专用优化方案 典型应用流程: 数据预处理(点云降噪/采样) 基元类型与参数设置 多阶段拟合(先平面后圆柱) 几何精度验证 误差控制在0.1%-1.2%范围内(视点云密度而定),适用于

weixin_45590420的博客 1161

BVH2SMPL 实战笔记

BVH2SMPL 实战笔记

jacke121的专栏 843

Spring中的IOC详解

单例Bean和多实例Bean的生命周期主要区别在于实例化和销毁的管理方式,单例Bean在容器启动时创建一个实例,并由容器负责管理其生命周期的完整过程。在Spring框架中,Bean是应用程序的核心组件,它们由Spring容器创建、组装和管理,以帮助开发者实现松耦合、可测试和可维护的代码。IOC的一个重点是在系统运行中,动态的向某个对象提供它所需要的其他对象。Bean的自动装配是Spring框架提供的一种便捷的方式,用于自动解析和设置Bean之间的依赖关系,而无需显式配置每一个依赖关系的方式。

努力分享一些干货 8635

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

学习Spring之Srping IOC运行时序图

加载XML文件——创建IOC容器时序图 源码理解 首先需要找到入口。IOC容器初始化运行的入口。 回顾 什么是SpringIOC IOC(Inversion Of Control)控制反转,所谓控制反转,就是把我们代码中需要实现的对象的创建、依赖。反转给容器来实现。同时需要一种描述让容器知道需要创建的对象和对象之间的关系。即配置文件。 寻找源码入口 1.关于BeanFactory ...

forBurnInG的专栏 332

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

SpringCloud

SpringCloud1.什么是微服务?2.微服务架构的优点?3.微服务架构的缺点?4.SpringCloud和SpringBoot的关系?5.SpringCloud和Dubbo的区别? 1.什么是微服务? 微服务化的核心就是将传统的一站式应用,根据业务拆分成一个一个服务,彻底的解耦,每一个微服务提供单个业务功能的服务,一个服务做一件事,从技术角度看就是一种小而独立的处理过程,类似进程的概念,能...................................................

weixin_43766298的博客 356

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

SpringIOC机制详解

所谓Bean的作用域其实就是指Spring给我们创建出的对象的存活范围,在配置文件中通过bean的scope属性指定取值范围说明singleton默认值,单例的prototype多例的requestWEB 项目中,Spring 创建一个 Bean 的对象,将对象存入到 request 域中sessionWEB 项目中,Spring 创建一个 Bean 的对象,将对象存入到 session 域中。

互联网底层民工的博客 9561

Spring IOC详细介绍

Spring IOC 1. 主要内容 2. Spring 框架 2.1. Spring 框架概念   Spring 是众多开源java项⽬中的⼀员,基于分层的javaEE应⽤⼀站式轻量级开源框架,主要核⼼是IOC(控制反转/依赖注⼊)与 AOP(⾯向切⾯)两⼤技术,实现项⽬在开发过程中的轻松解耦,提⾼项⽬的开发效率。   在项⽬中引⼊Spring⽴即可以带来下⾯的好处 降低组件之间的耦合度,实现软件各层之间的解耦。 可以使⽤容器提供的众多服务,如:事务管理服务、消息服务等等。 当我们使⽤容器管理事务时,

weixin_44454512的博客 2304

Spring源码学习

spring源码学习

qq_33816292的博客 287

Spring IOC超详解

Spring IOC 应⽤ 1.Spring IoC基础 1.1BeanFactory与ApplicationContext区别 BeanFactory是Spring框架中IoC容器的顶层接⼝,它只是⽤来定义⼀些基础功能,定义⼀些基础规范,⽽ApplicationContext是它的⼀个⼦接⼝,所以ApplicationContext是具备BeanFactory提供的全部功能的。 通常,我们称BeanFactory为SpringIOC的基础容器,ApplicationContext是容器的⾼级接⼝,⽐.

qq_39182939的博客 3078

一步一步手绘Spring IOC运行时序图一(Spring 核心容器 IOC初始化过程)

前言 1、博客内容均出自于咕泡学院架构师第三期 2、本章内容共分为三部分 第一部分:一步一步手绘Spring IOC运行时序图一(Spring 核心容器 IOC初始化过程) 第二部分:一步一步手绘Spring IOC运行时序图二(基于XML的IOC容器初始化) 第三部分:一步一步手绘Spring IOC运行时序图三(基于Annotation的IOC容器初始化) 1、Spring 核心之 IOC 容器初体验 IOC 与 DI IOC(Inversion of Control )控制反转:所谓控制反转,就是

Jarvis.y的博客 1369

SpringIOC初始化时序图

手绘SpringIOC时序图 通过绘制序图来一步步了解springIOC初始化的原理 总体来说,springIOC初始化可以分为三个模块------定位、加载和注册 再细分下去17个小模块 1.寻找入口——>2.获取配置文件路径——>3.容器开始启动——>4.开始解析配置文件路径——>5.载入配置路径——>6.分配路径处理策略——>7.解析配置...

qq_38762479的博客 1233

spring--绘制IoC时序图

一:什么是IoC IoC:Inversion of Control,控制反转的意思,获得依赖对象的过程由自身管理变为了由IOC容器主动注入,由容器来管理对象的生命周期。 二:时序图

qq47653423的博客 561

spring 解析Bean的时序图,AbstractApplicationContext,refresh()源码分析

因为spring的refresh()很复杂,为了简化只体现自己注解。 @SpringBootApplication() @ComponentScan(includeFilters = @ComponentScan.Filter()) public class Application { public static void main(String[] args) { Spr...

jackson的博客 383

Spring1.0 AbstractApplicationContext refresh()时序图

websequence title Spring1.0 AbstractApplicationContext refresh()时序图 AbstractApplicationContext-&gt;+AbstractApplicationContext: refreshBeanFactory() AbstractApplicationContext-&gt;Abstract...

siege 462

一条线总结Spring上下文refresh中原生接口调用顺序

Spring,上下文刷新流程

weixin_44008360的博客 368

spring-bean 全生命周期时序图

先来一段简单的代码 //获取资源 ClassPathResource resource = new ClassPathResource(&amp;amp;amp;amp;amp;amp;quot;spring-core.xml&amp;amp;amp;amp;amp;amp;quot;); //获取 BeanFactory DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); //根据新建的 BeanF

yzqingqing的博客 2469

spring bean初始化的完整生命周期

为了演示spring的生命周期,首先必须要加入spring的相关包新建一个SpringBoy类 实现BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean 要注意加入相关的包。 新建一个processor类,用于处理bean,叫作bean处理器,在xml中作如下配置: 分别实现它们的方法。

qq_32020353的博客 338
上一篇: Java-关于多线程可见性的一些问题
下一篇: Spring DI运行时序图以及源码分析
隙间光点
博客等级 码龄10年 29粉丝 80原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值