"# SpringCORE1" 1)Bean Factory Implementations with XmlBeanFactory: 2)XML BEAN Configurations: 3)Alien class: 4)Pom File Configurations: 5)After changing the deprecated part:
- Understanding Spring Container: A special container in JRE where it stores all spring Beans.
- Spring Beans are any objects or variables of Java classes having getters and setter methods.
- These Spring Beans are created only once by the JRE ---> called Singleton.
- ApplicationContext creates all the beans present in Sping.xml.
- Alien Object is created only once and reused. Obj1 and Obj2 are pointing to the same object.
What if we need more beans?
- For this we have an attribute scope. scope ="singleton" returns the same object whenever a new bean is required.
- For Multiple beans we need to change the scope to "prototype".
- If we use "prototype" as a scope we will not receive a bean until we ask for it.
- By default if we use singleton as a scope then ApplicationContext will create all the beans present in xml file before we ask for it.
Setters and Getters for Class Variables for Primitive Data Types: 1) 2) Right-click on age --> Source --> Generate Getters and Setters. 3)
Setters and Getters for Object / Reference types:
Constructor Injections:
We can Autowire Interfaces with attribute autowire="byName" and autowire="byType". When we would have 2 different objects of the classes implementing that interface, we use primary="true" to fix the primary bean.