Springbean life cycle

The life cycle of spring bean

The life cycle of spring bean: create, initialize, use, destroy,

1 create:

spring The bean is in singleton mode by default, and it is initialized in singleton mode by default.

2 Initialization:

Spring bean performs dependency injection;

If the bean If the beanNameAawre method is implemented, then the setBeanName method is called to transfer the id in springBean.

If the bean implements the applicationContextAware method, then the setApplicationContext method will be called to set the context,

If it is the beanfactory method, then the setBeanfactory method will be set in, and the BeanFactory instance will be passed in.

If the beanPostProcessr method is implemented, then the postProcessBeforeInitialization method will be called.

If the InitializingBean interface is implemented, spring will call its afterPropertiesSet interface method. Similarly, if the bean uses the init-method attribute to declare the initialization method, this method will also be called;

If implemented After beanPostProcessr method, the postProcessAfterInitialization method will be called.

3 Use

The use process is related to the call

4

To This is the usage process: Then it will be accompanied by the existence of the context until the destroy method is called

If the bean implements the DisposableBean interface, spring will call its distroy() interface method. Similarly, if the bean uses the destroy-method attribute to declare the destruction method, the method is called;

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4701 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.