Aryan PrajapatKnowledge Contributor
How we can set the spring bean scope. And what supported scopes does it have?
How we can set the spring bean scope. And what supported scopes does it have?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Questions | Answers | Discussions | Knowledge sharing | Communities & more.
There are four ways to set the scope of a Spring bean: singleton, prototype, request, and session.
The singleton scope creates a single instance of a bean, which is shared by all objects that request it.
The prototype scope creates a new instance of a bean for each object that requests it.
The request and session scopes are only available in a web-based context. The request scope creates a new bean instance for each HTTP request, and the session scope creates a single instance of a bean shared by all objects in a single HTTP session.