What is a bean in spring framework?
What is the use of the bean?
What is a bean in spring framework? What is the use of the bean?
Share
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.
In the context of Spring, a bean is a managed object. What is a managed object? It’s an object that Spring is aware of and that Spring knows how to manipulate, e.g. inject properties, invoke callback methods, etc.
There is then a difference between a regular java class (which Spring doesn’t know about) and beans (which Spring knows about).
Generally Spring beans follow the Java bean convention, so that Spring can manipulate them easily. For instance if the bean is declared to have a property
xxx, then Spring will expectgetXxxandsetXxxto be present. However, since Spring 2.X it is possible to dependency-inject private variables (using annotations), and therefore it is is no longer necessary to define a public setter in order to enable dependency injection for a property.( The term bean is confusing in the sense that it is frequently uses to denote either (1) something that is managed by a container, like an enterprise java bean (EJB) or (2) something that adheres to the Java bean conventions. )