Interview of spring, sprinBoot

The life cycle of Spring Bean?

 

Instantiation -> Attribute Assignment -> Initialization -> Destruction

  1. createBeanInstance() -> instantiate
  2. populateBean() -> attribute assignment, corresponding to the injection of the constructor and setter method
  3. initializeBean() -> initialization, users can customize the extension
  4. Destroyed when the container is closed.

Spring's core interface (commonly used)

Introduction to Spring's BeanPostProcessor (post processor) - Cloud + Community - Tencent Cloud (tencent.com)

BeanPostProcessor interface 

Function: It is to add our own logic before and after actively calling the initialization method after the Bean object is instantiated and dependency injected .

method

illustrate

postProcessBeforeInitialization

Instantiation and dependency injection are complete, and some custom initialization tasks are completed before calling the displayed initialization

postProcessAfterInitialization

Executed when instantiation, dependency injection, and initialization are complete

Usage learning:

おすすめ

転載: blog.csdn.net/u013372493/article/details/121925749