耶耶耶耶耶 发表于 2024-7-12 01:05:22

spring管理bean源码解析

1. 从启动类开始

public static void main(String[] args) {
      // Run the SpringApplication class with the Application class as the first argument
      SpringApplication.run(Application.class, args);
    }
2. bean 实例化

// SpringAplication row=1294
run()
// SpringAplication row=1035
run()
// SpringAplication row=308
refreshContext(context);
//SpringAplication row=407
refresh(context);
//SpringAplication row=734
applicationContext.refresh();

// AbstractApplicationContext row=583
finishBeanFactoryInitialization(beanFactory);
// AbstractApplicationContext row=918
beanFactory.preInstantiateSingletons();

// DefaultListableBeanFactory row=922
preInstantiateSingletons();

// AbstractBeanFactory row=207
getBean();
// AbstractBeanFactory row=248
goGetBean()
// AbstractAutowareCapableBeanFactory row=503
createBean()
3. bean 依赖注入

// SpringAplication row=1294
run()
// SpringAplication row=1035
run()
// SpringAplication row=308
refreshContext(context);
//SpringAplication row=407
refresh(context);
//SpringAplication row=734
applicationContext.refresh();

// AbstractApplicationContext row=583
finishBeanFactoryInitialization(beanFactory);
4. 删除实例及其依赖实例

// DefaultSingletonBeanRegistry row=550
destroySingleton()
// DefaultSingletonBeanRegistry row=568
destroyBean()
// AbstractFactoryBean row=197
destroy()

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: spring管理bean源码解析