1. Set the scope of the bean
When you create a bean instance from a Spring IOC container, you can not only instantiate the bean, but also specify a specific scope for the bean, and Spring supports the following 5 scopes:
1. Singleton: Single case mode. In the entire IOC container, the bean instance defined with Singleton will have only one.
2. Prototype: Prototype mode, each time a prototype defined bean is obtained through the container's Getbean method, a new bean instance is generated
3. Request: For each HTTP request, the bean defined with the request will produce a new instance, that is, each HTTP request will produce a different bean instance. The scope is valid only if you are using spring in a web app
4.session: For each HTTP session, a new instance is generated using bean Soymilk defined by session. The scope is also valid only if spring is used in the Web App
5. Spring Config bean via XML (Advanced)