Bean scope in spring - Java @ Desk

Friday, June 21, 2013

Bean scope in spring

When we declare a bean in spring, there is a feature to define the scope of that bean in the configuration file. In spring, there are 5 different types of scopes as shown below:

Scope Explanation
singleton Return a single bean instance per Spring IoC container
prototype Return a new bean instance each time when requested
request Return a single bean instance per HTTP request
session Return a single bean instance per HTTP session
globalsession Return a single bean instance per global HTTP session






1 comment: