Skip to content

pranjalisingh1201/SpringCORE1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

"# SpringCORE1" 1)Bean Factory Implementations with XmlBeanFactory: image 2)XML BEAN Configurations: image 3)Alien class: image 4)Pom File Configurations: image 5)After changing the deprecated part: image

  1. Understanding Spring Container: A special container in JRE where it stores all spring Beans.
  2. Spring Beans are any objects or variables of Java classes having getters and setter methods.
  3. These Spring Beans are created only once by the JRE ---> called Singleton. image
  4. ApplicationContext creates all the beans present in Sping.xml.
  5. Alien Object is created only once and reused. Obj1 and Obj2 are pointing to the same object. image image

What if we need more beans?

  1. For this we have an attribute scope. scope ="singleton" returns the same object whenever a new bean is required.
  2. For Multiple beans we need to change the scope to "prototype". image
  3. If we use "prototype" as a scope we will not receive a bean until we ask for it.
  4. 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. image

Setters and Getters for Class Variables for Primitive Data Types: 1)image 2) Right-click on age --> Source --> Generate Getters and Setters. image 3)image

Setters and Getters for Object / Reference types:

  1. image
  2. image
  3. image
  4. image

Constructor Injections:

  1. image
  2. Setter methods are not called and the constructor assigns variables and references.
  3. image

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.

Releases

No releases published

Packages

No packages published

Languages