Singleton versus prototype bean

In Spring, by default, all beans defined are singleton; however, we can change the default behavior and make our bean prototype. When the bean scope is set to prototype, the Spring IoC container creates a new bean instance of an object every time a bean is requested. Prototype beans incur a hit on performance during creation, so when a prototype bean uses resources, such as network and database connection, it should be avoided completely; alternatively, design the action carefully.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset