A brain map to master the life cycle of spring bean

Time:2020-11-16

A brain map to master the life cycle of spring bean

Well, interviewer, before I start, I’ll talk about two common scopes:singletonandprototype

  • Spring container can be managedsingletonThe lifecycle of a scoped bean, in which spring knows exactly when the bean is created, initialized, and destroyed.
  • aboutprototypeSpring is only responsible for creating a scope bean. When the container creates an instance of a bean, the bean instance will be handed over to the client code management, and the spring container will no longer track its life cycle. Every client requestprototypeThe spring container creates a new instance of the scope bean, regardless of whether those instances are configured asprototypeThe lifecycle of the scoped bean.

in other words,singletonSpring manages the lifetime of type bean, andprototypeType bean is only created by spring. Once created, it is no longer managed by spring.

Now I’ll give you a picture to show bean’s life, manual dog head.

A brain map to master the life cycle of spring bean

A brain map to master the life cycle of spring bean

A brain map to master the life cycle of spring bean

Finally, I think I have to give this picture to you so that you can pass the interview successfully!

Pay attention to the official account and reply:Bean's life, get HD brain map + XMIND file, of course, there are more wonderful articles!

A brain map to master the life cycle of spring bean

Recommended Today

Kubernetes practice of New Oriental: from service oriented es to Kafka and redis

In 2017, New Oriental began to explore the use of containerization to serve middleware business, using ES based on rancher 1.6; in 2019, New Oriental started to expand the service of middleware business again, using Kafka, ES and redis based on kubernetes. What problems does New Oriental encounter in the process of servitization? What are […]