What Is a Bean: Definition, Registration, Instantiation and Naming
Learn What Is a Bean: Definition, Registration, Instantiation and Naming (Phase 3 · Spring Beans (Essential), Spring Core) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What is a Spring bean? • A bean is an object that is instantiated, assembled and managed by the Spring IoC container . Any class can be a bean (a POJO); what makes it a bean is that the container created it from a bean definition . Objects you create with new yourself are not beans (no injection, no AOP). • A BeanDefinition is the recipe: class name, scope, constructor arguments and property values, dependencies ( depends-on ), lazy flag, init/destroy method names, primary/autowire candidate flags, factory method. The registry ( BeanDefinitionRegistry , i.e. the bean factory) stores...