Spring Framework: Dependency Injection Ioc Container Bean Creation Spring Beans Autowiring Springmvc

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

Spring Framework

Dependency Injection
IOC container
Bean Creation
Spring Beans
Autowiring
SpringMVC
Dependency Injection
Java components / classes should be as independent as
possible of other Java classes.

Dependency Injection is the way in which we make java


components/ classes independent of each other.

Dependency Injection can be achieved without spring


framework also.

Spring framework makes easier to achieve Dependency


Injection.
Types of Dependency Injections:

1.Setter Injection
2.Constructor Injection

Setter Injection and Constructor Injection:


A class A has a dependency to class B if class A uses
class B as a variable.
If class B is injected to class A

via a setter - this is then called setter injection


via a constructor then called constructor injection
Factory Pattern
Spring uses factory pattern for creation of spring beans

Object Object Factory

Configuration file
Application context and Web application context

Application Context is an interface, therefore it


cannot be instantiated.

To instantiate one of the (non-abstract) classes that


implement the application Context interface.

Web application context is also an interface and is


used in Spring MVC applications.

Beans, instantiated in Web application Context will


also be able to use Servlet Context.
Spring IOC container:

The Inversion of Control is the process by which


application defines the dependency and these
dependencies are then satisfied in runtime by the
Spring Framework.

The IOC container is the main component of the


Spring framework.

The core container of the Spring Framework provides


dependency injection and bean lifecycle
management.
Autowiring
Autowiring by name

Autowiring by type

You might also like