随笔分类 -  Spring源码

摘要:Bean 的生命周期示意图(存在循环依赖和 AOP) 执行创建 Bean protected Object doCreateBean(String beanName, RootBeanDefinition mbd, @Nullable Object[] args) throws BeanCreati 阅读全文
posted @ 2022-03-31 23:19 天航星 阅读(31) 评论(0) 推荐(0) 编辑
摘要:项目地址 https://gitee.com/liao-hang/hand-write-spring.git 模拟 Spring 注解 自动装配 Autowired @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) publ 阅读全文
posted @ 2022-03-31 23:19 天航星 阅读(41) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 主要有两种实现方式:XML 和注解。 Spring 3.0 推出了注解注入,成为了现在的主流,也是官方推荐的。 这里分析注解方式。 AnnotationConfigApplicationContext(AppConfig.class) AppConfig package cn. 阅读全文
posted @ 2022-03-31 18:03 天航星 阅读(44) 评论(0) 推荐(0) 编辑
摘要:前面实现了 ClassPathXmlApplicationContext 的构造,接下来分析其调用的 getBean 方法。 以 getBean(UserDao.class) 为例。 1 AbstractApplicationContext public <T> T getBean(Class<T> 阅读全文
posted @ 2022-03-14 14:02 天航星 阅读(76) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 13 个:resetCommonCaches。 1 AbstractApplicationContext 1-1 清空缓存 resetCommo 阅读全文
posted @ 2022-03-14 14:01 天航星 阅读(86) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 12 个:finishRefresh。 1 AbstractApplicationContext 1-1 完成刷新过程 finishRefres 阅读全文
posted @ 2022-03-14 14:00 天航星 阅读(54) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 10 个:registerListeners。 1 AbstractApplicationContext 1-1 注册监听器 registerL 阅读全文
posted @ 2022-03-14 14:00 天航星 阅读(64) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 11 个:finishBeanFactoryInitialization。 1 AbstractApplicationContext 1-1 初 阅读全文
posted @ 2022-03-14 14:00 天航星 阅读(41) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 9 个:onRefresh。 1 AbstractApplicationContext 1-1 特定刷新 onRefresh() protect 阅读全文
posted @ 2022-03-14 13:59 天航星 阅读(34) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 6 个:registerBeanPostProcessors。 1 AbstractApplicationContext 1-1 注册 Bean 阅读全文
posted @ 2022-03-14 13:58 天航星 阅读(37) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 7 个:initMessageSource。 1 AbstractApplicationContext 1-1 初始化 message 源 in 阅读全文
posted @ 2022-03-14 13:58 天航星 阅读(50) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 8 个:initApplicationEventMulticaster。 1 AbstractApplicationContext 1-1 初始 阅读全文
posted @ 2022-03-14 13:58 天航星 阅读(40) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 4 个:postProcessBeanFactory。 1 AbstractApplicationContext 1-1 定义 Bean 工厂的 阅读全文
posted @ 2022-03-14 13:57 天航星 阅读(36) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 5 个:invokeBeanFactoryPostProcessors。 1 AbstractApplicationContext 1-1 执行 阅读全文
posted @ 2022-03-14 13:57 天航星 阅读(40) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 2 个:obtainFreshBeanFactory。 1 AbstractApplicationContext 1-1 创建容器对象 obta 阅读全文
posted @ 2022-03-14 13:56 天航星 阅读(53) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 3 个:prepareBeanFactory。 1 AbstractApplicationContext 1-1 对 BeanFactory 进 阅读全文
posted @ 2022-03-14 13:56 天航星 阅读(31) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 的核心是 AbstractApplicationContext 的 refresh 方法。 其中一共有 13 个主要方法,这里分析第 1 个:prepareRefresh。 1 AbstractApplicationContext 1-1 刷新前的准备工作 prepareRef 阅读全文
posted @ 2022-03-01 16:39 天航星 阅读(50) 评论(0) 推荐(0) 编辑
摘要:Spring IOC 主要有两种实现方式:XML 和注解。 这里分析 XML 方式。 ClassPathXmlApplicationContext("applicationContext.xml") 配置文件 首先看解析的对象:配置文件。 <?xml version="1.0" encoding=" 阅读全文
posted @ 2022-02-26 18:01 天航星 阅读(43) 评论(0) 推荐(0) 编辑
摘要:总流程 基本接口 IOC 容器两种实现方式:BeanFactory 和 ApplicationContext。 BeanFactory 容器的根接口,也是容器的入口。 Spring 内部使用的接口,不推荐开发人员使用。 加载配置文件的时候不会创建对象,在获取对象(使用)才去创建对象。 必须遵循完成的 阅读全文
posted @ 2022-02-26 18:00 天航星 阅读(38) 评论(0) 推荐(0) 编辑
摘要:环境信息 JDK 17.0.2 Gradle 7.4 IntelliJ IDEA 2021.3.2 获取项目 GitHub 搜索 访问 GitHub 官网:https://github.com/ 输入 spring 选择 spring-projects / spring-framework Spri 阅读全文
posted @ 2022-02-26 17:59 天航星 阅读(264) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示