{"id":20912553,"url":"https://github.com/fuzhengwei/book-small-spring","last_synced_at":"2025-04-07T11:11:03.273Z","repository":{"id":62943388,"uuid":"494652943","full_name":"fuzhengwei/book-small-spring","owner":"fuzhengwei","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-05T23:21:20.000Z","size":3536,"stargazers_count":230,"open_issues_count":6,"forks_count":124,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-31T10:06:07.493Z","etag":null,"topics":["spring"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fuzhengwei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-21T01:47:27.000Z","updated_at":"2025-03-26T00:07:36.000Z","dependencies_parsed_at":"2024-11-18T14:52:11.315Z","dependency_job_id":"14ff07be-d94f-4207-9bab-0a23ce1c3e7a","html_url":"https://github.com/fuzhengwei/book-small-spring","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuzhengwei%2Fbook-small-spring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuzhengwei%2Fbook-small-spring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuzhengwei%2Fbook-small-spring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuzhengwei%2Fbook-small-spring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fuzhengwei","download_url":"https://codeload.github.com/fuzhengwei/book-small-spring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640465,"owners_count":20971557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["spring"],"created_at":"2024-11-18T14:32:09.085Z","updated_at":"2025-04-07T11:11:03.238Z","avatar_url":"https://github.com/fuzhengwei.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 《手写Spring：渐进式源码实践》 —— 书籍源码库\n\n![](https://github.com/fuzhengwei/book-small-spring/blob/master/doc/book-01.png?raw=true)\n\n本项目思路和代码来自于开源项目 [DerekYRC/mini-spring](https://github.com/DerekYRC/mini-spring)、[code4craft/tiny-spring](https://github.com/code4craft/tiny-spring) 经过本人学习、扩展、补充，并编写文章总结经验，分享给广大读者，一起学习 Spring 源码。非常感谢开源项目贡献者，读者也可以一起学习，不同视角下的学习经验。\n\n**开源项目及优秀书籍**；\n\n- [DerekYRC/mini-spring](https://github.com/DerekYRC/mini-spring)\n- [code4craft/tiny-spring](https://github.com/code4craft/tiny-spring)\n- [《Spring源码深度解析》](https://item.jd.com/12506664.html)\n- [《精通Spring 4.x —— 企业应用开发实战》](https://item.jd.com/10062905219396.html)\n\n---\n\n👨‍💻作者：小傅哥\n\u003cbr/\u003e\n🌱微信：fustack —— 可以添加微信备注【Spring读书群📚】\n\n\u003e沉淀、分享、成长，让自己和他人都能有所收获！\n\n`IOC`、`AOP`、`SPI`，Spring 给你的不只是一个开发框架，还包括它的设计思想。它通过解耦 Bean 对象的实例化过程，管理 Bean 的生命周期，来维护你在程序开发中所需对象使用过程。让你不需要刀耕火种般 new 一个对象，也不需要如 EJB 一样笨重臃肿的开发维护，而像春风一样润物(`万物皆可Bean`)细无声的使用。因此可以说它完全担得起 **Java 技术设计的顶峰**。\n\u003cbr/\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://u.jd.com/4LapTH4\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://github.com/fuzhengwei/book-small-spring/blob/master/doc/book.png?raw=true\" width=\"250px\"\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\n除了运用以外，Spring 框架也是众多码农，最能最先接触到的一个**源码级复杂项目**。任何初出新手村蜕变的码农，寻觅苦找的锻炼项目，都不如学习 Spring 源码来的痛快。从架构设计的复杂、从分治抽象的运用、从设计模式的驾驭，Spring 框架都是顶级的，也是最能给你带来丰富收获的。\n\n---\n\n**📝目录**\n\n0. 代码仓库\n    - GitHub：[https://github.com/fuzhengwei/book-small-spring](https://github.com/fuzhengwei/book-small-spring)\n    - Gitcode：[https://gitcode.net/fuzhengwei/book-small-spring](https://gitcode.net/fuzhengwei/book-small-spring)\n1. 本书特点\n2. 学以致用\n3. [书籍购买](https://u.jd.com/4LapTH4)\n4. 勘误记录 —— `非常感谢，读者提交阅读中发现的错字和问题。`\n\n---\n\n## 1. 本书特点\n\n1. 这本书最大的价值是带着想学Spring源码的读者，能有个门进去。避免像以前一样，东一榔头西一棒子没有体系化的学。\n2. 手写spring，不是为了再造一个轮子，是为了吸收更好的架构设计和编程思想。并把内容运用到实际项目，既可以解决业务的耦合实现，提升交付质量。\n3. 本书采用从零手写 Spring 的方式，摒弃 Spring 源码中繁杂的内容，选择整体框架中的核心逻辑，简化代码实现过程，保留核心功能，如 IOC、AOP、Bean 的生命周期、上下文、 作用域和资源处理、事务等。在开发过程中，细化功能模块，逐步完成一个简单版的 Spring 框架。\n\n## 2. 学以致用\n\n[《手写Spring：渐进式源码实践》](https://u.jd.com/4LapTH4)完成后我的能力如何体现在简历上？给个案例。\n\n1. **体现在专业技能上**，例如；\n    1. 深入学习 Spring 核心流程模块，包括；IOC、AOP、依赖倒置等流程，掌握Spring解决复杂场景所运用的分治、抽象和知识(设计模式、设计原则)，在解决Spring场景问题时，可以从核心原理上给出方案。同时也具备基于 Spring 开发 SpringBoot Starter 技能，为复杂项目减少同类共性需求的开发，凝练通用的技术组件，减少研发成本。\n    2. 深入学习 MyBaits 核心流程模块，包括；会话、反射、代理、事务、插件等流程，熟练掌握 ORM 框架的设计思想、实现方式和应用价值。并能按需结合 MyBatis 的插件机制，开发属于企业自己所需的功能，包括；数据分页、数据库表路由、监控日志、数据安全等方面。\n\n2. **体现在项目经验上**，例如；—— 对校招和实习比较有用\n把 Spring、MyBatis 当一个学习项目来描述，这是你在离校前，最可能接触到的一个完整的、成型的、知名的，有企业使用的，框架。你就按照自己学习并开发了这样一个框架为目标来写项目，并描述出这个项目，你用了什么技术栈，解决了什么问题，学习到了哪些。\n\n3. **体现在项目应用上**，例如；\n关于 Spring、MyBatis 的项目，一般都是插件类开发，比如各类的 SpringBoot Starter，MyBatis 插件，都是基于框架的深入整合类技术解决方案，体现在简历上，非常抓眼球。一看你就是有深度和自研能力的研发人员。—— 一般不让你造轮子，但需要你有造轮子的能力，这样企业中一些软件可以被你进行优化和修改。\n\n4. **体现在解决问题上**，例如；\n在你的自己的业务项目中，渗入一些关于解决了原项目使用 Spring 时，关于感知 Aware 方式或者结合 FactoryBean 包装对象等，所遇到的问题，因为你学习过源码，所以非常清晰这样的流程，因此解决了一个问题。通用 MyBatis 也适用于这样的描述方式，包括；事务、查询次数、批查询、插件能监听到的四个类（ParameterHandler、ResultSetHandler、StatementHandler、Executor ）你给了更好的选择。\n\n## 3. 书籍购买\n\n**链接下单**：[https://u.jd.com/4LapTH4](https://u.jd.com/4LapTH4)\n\n本书共21章；\n- 第01 ~ 10章：主要介绍IOC 容器，逐步完善一个简单的Spring Bean 容器的相关功能，引入实例化策略、注入属性和依赖、设计应用上下文、处理Bean 对象的生命周期，以及实现感知容器对象的监听等。\n- 第11 ~ 12章：主要介绍AOP 切面，基于JDK、Cglib 的动态代理、方法拦截、切点表达式等技术，将代理与Spring Bean 容器整合，提供AOP 切面功能。\n- 第13 ~ 17章：扩展简单版Spring 框架的自动化功能，完成自动扫描注册、注解和代理注入，以及通过三级缓存处理对象的循环依赖等功能。\n- 第18 ~ 21章：基于简单实现的Spring 框架整合JDBC、事务的功能，开发一个简单版的ORM 框架，并将ORM 框架整合到Spring Bean 容器中，介绍自定义代理对象的扫描和注册过程。\n\n本书主要通过渐进式开发功能模块，以实现开发整个Spring 框架的核心源码。首先，每章开头都会列出难度和重点；然后，正文中会介绍要处理的问题、具体设计和实现代码；最后，给出测试验证和本章总结。\n\n## 4. 勘误记录\n\n### 1. 第3页，Spring 框架地图\n\n- 错误：`BeanPostProcessor 前置处理 | postProcessAfterInitializtion` \n- 修改：`BeanPostProcessor 后置处理 | postProcessAfterInitializtion` \n\n### 2. 第17页，图 2-2 类图错误\n\n- 错误：图 2-2 DefaultSingletonBeanRegistry #addSingleton 类图与代码不符\n- 修改：图 2-2 DefaultSingletonBeanRegistry #registerSingleton\n\n### 3. 第5页，工程示意图调整\n\n- 错误：SpringTutorials\n- 修改：book-small-spring \n- 说明：因为作者github中项目较多，所以统一修改了工程名称，方便读者知道book开头的是项目工程是图书库代码。\n\n### 4. 第27页，工程结构，颜色标记 感谢 反馈人：@苏沐\n\n- 错误：DefaultListableBeanFactory 绿色标记\n- 修改：DefaultListableBeanFactory 黑色标记\n- 说明：绿色为新增，DefaultListableBeanFactory 非新增类，为黑色。\n\n### 5. 第52页，图 5-4 感谢 反馈人：@水中捞月、@INIT\n\n- 错误：BeanFactory 多了一个 registerBeanDefinition 方法\n- 修改：删除掉 registerBeanDefinition 方法，并在 BeanFactory 标记`《接口》`\n\n### 6. 第167页，图 12-1 感谢 反馈人：@🍇葡萄\n\n- 错误：图中 ProxyFacory 单词错误\n- 修改：ProxyFacory 修改为 ProxyFactory\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuzhengwei%2Fbook-small-spring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuzhengwei%2Fbook-small-spring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuzhengwei%2Fbook-small-spring/lists"}