spring web 生命周期理解

spring web /bean 生命周期

init servlet  初始化

    load spring-context.xml

    load XmlParser 类解析对象   bean or aop or component-scan or the readding properties 

         // bean

         create bean

         配置bean 属性

         判断 BeanNameAware接口->setBeanName

         判断 BeanFactoryAware接口-> setBeanFactory

         判断 InitializingBean接口 -> afterPropertiesSet

         判断 init-method 属性,调用 bean init

         判断 BeanPostProcessors接口->processAfterInitialization

service servlet   http请求

destroy servlet  销毁

         //bean 

         判断 DisposableBean接口->destroy

         判断 destroy-method属性 调用

以上bean的生命周期可以概括为:

   Bean创建

   Bean属性注入

   Bean 初始化

   Bean销毁

spring boot

    spring boot main : org.springframework.boot.loader.JarLauncher

    读取appilcation.properties or yml文件

    加载servlet

       main扫描注解 初始化Autowired 初始化bean RequestMapping 。。。

    

    其它同上

猜你喜欢

转载自www.cnblogs.com/a-xu/p/9726289.html
今日推荐