<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>框架 on 技术笔记</title><link>https://elliot-blog.com/categories/%E6%A1%86%E6%9E%B6/</link><description>Recent content in 框架 on 技术笔记</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Sun, 18 Jan 2026 02:24:22 +0800</lastBuildDate><atom:link href="https://elliot-blog.com/categories/%E6%A1%86%E6%9E%B6/index.xml" rel="self" type="application/rss+xml"/><item><title>spring源码理解bean生命周期</title><link>https://elliot-blog.com/posts/202512/spring_source_code/</link><pubDate>Sat, 06 Dec 2025 19:36:02 +0800</pubDate><guid>https://elliot-blog.com/posts/202512/spring_source_code/</guid><description>&lt;h1 id="spring-ioc-源码理解"&gt;spring IOC 源码理解&lt;/h1&gt;
&lt;p&gt;注：本文参考 spring版本6.2.10，各个大版本可能有一些细微区别，但大致原理相同&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;本文不准备贴大段的代码，那个并没有什么特别的意义，除非特别关键的。阅读框架的思想是抽象大于细节，找到最高层次的抽象，找到入口函数。理解思想。对于spring bean 的ioc容器，而且最后搜集到一个concurrenthashmap中去。主线就是bean的生命周期管理。从bean的搜集-&amp;gt;初始化-&amp;gt;成熟-&amp;gt;销毁。这是一个相当简化的模型，结合了相当多的回调函数，但是核心还是继承了beanFactoryPostProcessor和beanPostProcessor这两个接口，甚至你会发现所谓的bean搜集，就是beanFactoryPostProcessor的子接口BeanDefinitionRegistryPostProcessor的做的，aop切面则是beanPostProcessor做的。&lt;/li&gt;
&lt;li&gt;spring beans这个包有着比较重要的几个抽象接口，下面依次说明。在阅读代码的时候建议之间查看uml图，重点查看继承关系，特别是这种框架代码很多模版方法，很多具体的细节在抽象类而不是具体实现类。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="spring-ioc"&gt;spring IOC&lt;/h2&gt;
&lt;h3 id="入口函数"&gt;入口函数&lt;/h3&gt;
&lt;p&gt;spring的最重要的函数是AbstractApplicationContext的refresh函数，这里是一切的起点。建议阅读源码的时候从这里开始打断点，你可以一步一步进去看看是怎么做的。&lt;/p&gt;</description></item></channel></rss>