Singleton scope: When a bean definition is set to singleton scope, only one shared bean instance exists in the Spring IOC container, and all of the Bean's
request, as long as the ID matches the bean definition, only the same instance of the bean is returned. It is worth emphasizing that the singleton scope is the default scope in spring.
prototype scope:prototype-scoped beans cause each request to the bean to be injected into another bean, or to invoke the container's Getbean programmatically
() method) will create a new bean instance. Based on experience, you should use the prototype scope for stateful beans, while for stateless beans you should use the Singleton action
domain.
for beans with prototype scope, it is important to note that spring cannot be responsible for the entire life cycle of the bean. A bean with a prototype scope is created and handed
The user is responsible for destroying the object recycling resources.
to put it simply:
Singleton has only one instance, which is a singleton mode. (default)
prototype Access creates one instance at a time, equivalent to new.
Application:
1. The need to reclaim important resources (database connections, etc.) is configured as Singleton, and if configured for prototype requires an application to ensure that resources are properly reclaimed.
2. Stateful beans configured as Singleton will cause unknown problems and can be considered configured as prototype.
Java records Two modes of the-SPRINGMVC scope property