keyword: Spring IOC bean's scope attribute value: Prototype and Singleton
Spring IOC Bean's scope attribute value: Prototype and Singleton
If the specified bean is scoped to scope= "prototype" in <bean>, the bean is returned to the caller, who is responsible for the bean
Later life management, spring no longer manages the lifecycle of these beans. If the scope is set to Scope= "Singleton", the
The bean is placed into the cache pool of the spring IOC container, and the bean reference is returned to the caller, and spring continues to follow the bean
Management of life. The default property is Singleton
The bean exists in two forms: the Singletons form and the prototypes form. When a bean exists in singletons form, Beanfactory manages only one shared instance. All instance requests to this particular bean cause a reference to be returned for this unique bean instance.
When the bean is in prototype form, each instance request to the bean causes a new instance to be created. This is an ideal solution when users need objects that are not affected by other user objects or have similar requirements.
The bean defaults to exist in singleton form unless you explicitly specify it otherwise. Be careful that when you change the bean's setting to prototype mode, each instance request to the bean causes a new bean instance to be created, which may not be what you expect. So, you should only set the bean to prototype mode when you really need it