SlideShare a Scribd company logo
What is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection?
Inversion of Control
Types of Dependency Injection
Benefits of Dependency Injection
Implement Dependency Injection Using Spring Boot
www.edureka.co
www.edureka.co
Class ClassA uses methods of B
Class A is Dependent on B
www.edureka.co
Class ClassBefore A uses methods of B
Class A needs to create an instance of class B
www.edureka.co
The process of creating an object for some other class and let the class directly using the
dependency is called dependency injection.
What is Dependency Injection(DI)?
Class DI
I need two objects
www.edureka.co
The process of creating an object for some other class and let the class directly using the
dependency is called dependency injection.
What is Dependency Injection(DI)?
Class
DI
Create Objects
A objectA = new A()
B objectB = new B()
www.edureka.co
The process of creating an object for some other class and let the class directly using the
dependency is called dependency injection.
What is Dependency Injection(DI)?
Class DI
Returns objects to the class
www.edureka.co
Dependency Injection uses three types of classes. The injector class creates an object of
the service class. Then, the injector class injects the object to a client object.
What is Dependency Injection(DI)?
Client
Class
Injector
Class
Service
Class
www.edureka.co
www.edureka.co
Concept Behind Dependency Injection
A class should not configure its dependencies statically but should be
configured by some other class from outside.
A class should concentrate on fulfilling its responsibilities like the flow of an
application, and not on creating objects
www.edureka.co
www.edureka.co
Dependencies are
provided through a
class constructor
Injector method injects
the dependency to the
setter method exposed
by the client.
Injector uses Interface
to provide the
dependency to the client
class.
Constructor Setter Interface
www.edureka.co
www.edureka.co
Email Service
Class
Objects
1. To email address
2. From email address
3. Subject
4. Body
www.edureka.co
Email Service
Class Recreate the Class
www.edureka.co
Using Dependency Injection
Change Objects at run time
www.edureka.co
Reduction of
Boiler plate
code
Unit Testing is
made much
easier
Application can
be easily
extended
Enables an easy way
to interconnect the
components
01 02 03 04
www.edureka.co
www.edureka.co
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
www.edureka.co

More Related Content

PPTX
Introduction to Spring Framework
PPTX
Solid principles
PDF
Introduction to Spring's Dependency Injection
PDF
Java Design Patterns Tutorial | Edureka
PDF
Dependency Injection
PPTX
Dependency injection - the right way
PDF
Spring Framework - Core
PPT
Spring Core
Introduction to Spring Framework
Solid principles
Introduction to Spring's Dependency Injection
Java Design Patterns Tutorial | Edureka
Dependency Injection
Dependency injection - the right way
Spring Framework - Core
Spring Core

What's hot (20)

ODP
Introduction to Spring Framework and Spring IoC
PPTX
Spring boot
PPT
Spring ppt
PDF
Gradle Introduction
PPTX
Object oreinted php | OOPs
PPTX
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
PDF
Dependency Injection
PPSX
Spring - Part 1 - IoC, Di and Beans
PPTX
Spring boot Introduction
PPTX
Reactjs
PDF
Genesis and Overview of Java
PPTX
Spring jdbc
PPTX
JDBC ppt
PDF
Hibernate Presentation
PPTX
Angular 9
PPTX
Java RMI
PPTX
Spring Framework Petclinic sample application
PDF
REST APIs with Spring
PPTX
Spring Security 5
PPT
JDBC – Java Database Connectivity
Introduction to Spring Framework and Spring IoC
Spring boot
Spring ppt
Gradle Introduction
Object oreinted php | OOPs
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Dependency Injection
Spring - Part 1 - IoC, Di and Beans
Spring boot Introduction
Reactjs
Genesis and Overview of Java
Spring jdbc
JDBC ppt
Hibernate Presentation
Angular 9
Java RMI
Spring Framework Petclinic sample application
REST APIs with Spring
Spring Security 5
JDBC – Java Database Connectivity
Ad

Similar to What is Dependency Injection in Spring Boot | Edureka (20)

PPTX
Dependency Injection in Java Essential for Building Maintainable Projects in ...
PDF
Dependency injection Flash Talk
PDF
Dependency injection
PPTX
C# Dependency Injection Tutorial | C# Dependency Injection Example | C# Tutor...
PDF
Dependency injection for beginners
PPT
Dependency injection
PPTX
Dependency Inversion Principle
PPTX
Di – ioc (ninject)
PDF
Techlunch - Dependency Injection with Vaadin
PPTX
Dependency Inversion Principle
PPTX
Neoito — Design patterns and depenedency injection
ODP
Dependency injection explained (Zbigniew Lukasiak)
PPTX
How to implement dependency injection in c#
PPTX
Clean Code II - Dependency Injection
PPTX
Dependency Injection and Autofac
PPTX
Dependency injection
PPTX
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
PDF
Real World Dependency Injection - PFCongres 2010
PDF
Dependency Injection in iOS
PPTX
Dependency injection using Google guice
Dependency Injection in Java Essential for Building Maintainable Projects in ...
Dependency injection Flash Talk
Dependency injection
C# Dependency Injection Tutorial | C# Dependency Injection Example | C# Tutor...
Dependency injection for beginners
Dependency injection
Dependency Inversion Principle
Di – ioc (ninject)
Techlunch - Dependency Injection with Vaadin
Dependency Inversion Principle
Neoito — Design patterns and depenedency injection
Dependency injection explained (Zbigniew Lukasiak)
How to implement dependency injection in c#
Clean Code II - Dependency Injection
Dependency Injection and Autofac
Dependency injection
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
Real World Dependency Injection - PFCongres 2010
Dependency Injection in iOS
Dependency injection using Google guice
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
PDF
Top 5 Trending Business Intelligence Tools | Edureka
PDF
Tableau Tutorial for Data Science | Edureka
PDF
Python Programming Tutorial | Edureka
PDF
Top 5 PMP Certifications | Edureka
PDF
Top Maven Interview Questions in 2020 | Edureka
PDF
Linux Mint Tutorial | Edureka
PDF
How to Deploy Java Web App in AWS| Edureka
PDF
Importance of Digital Marketing | Edureka
PDF
RPA in 2020 | Edureka
PDF
Email Notifications in Jenkins | Edureka
PDF
EA Algorithm in Machine Learning | Edureka
PDF
Cognitive AI Tutorial | Edureka
PDF
AWS Cloud Practitioner Tutorial | Edureka
PDF
Blue Prism Top Interview Questions | Edureka
PDF
Big Data on AWS Tutorial | Edureka
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
PDF
Kubernetes Installation on Ubuntu | Edureka
PDF
Introduction to DevOps | Edureka
What to learn during the 21 days Lockdown | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Tableau Tutorial for Data Science | Edureka
Python Programming Tutorial | Edureka
Top 5 PMP Certifications | Edureka
Top Maven Interview Questions in 2020 | Edureka
Linux Mint Tutorial | Edureka
How to Deploy Java Web App in AWS| Edureka
Importance of Digital Marketing | Edureka
RPA in 2020 | Edureka
Email Notifications in Jenkins | Edureka
EA Algorithm in Machine Learning | Edureka
Cognitive AI Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Blue Prism Top Interview Questions | Edureka
Big Data on AWS Tutorial | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Kubernetes Installation on Ubuntu | Edureka
Introduction to DevOps | Edureka

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Approach and Philosophy of On baking technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
cuic standard and advanced reporting.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPT
Teaching material agriculture food technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Machine learning based COVID-19 study performance prediction
sap open course for s4hana steps from ECC to s4
The Rise and Fall of 3GPP – Time for a Sabbatical?
Approach and Philosophy of On baking technology
The AUB Centre for AI in Media Proposal.docx
cuic standard and advanced reporting.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Teaching material agriculture food technology
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Chapter 3 Spatial Domain Image Processing.pdf
A Presentation on Artificial Intelligence
Electronic commerce courselecture one. Pdf
NewMind AI Weekly Chronicles - August'25-Week II
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Review of recent advances in non-invasive hemoglobin estimation
Machine learning based COVID-19 study performance prediction

What is Dependency Injection in Spring Boot | Edureka

  • 2. What is Dependency Injection? Inversion of Control Types of Dependency Injection Benefits of Dependency Injection Implement Dependency Injection Using Spring Boot www.edureka.co
  • 4. Class ClassA uses methods of B Class A is Dependent on B www.edureka.co
  • 5. Class ClassBefore A uses methods of B Class A needs to create an instance of class B www.edureka.co
  • 6. The process of creating an object for some other class and let the class directly using the dependency is called dependency injection. What is Dependency Injection(DI)? Class DI I need two objects www.edureka.co
  • 7. The process of creating an object for some other class and let the class directly using the dependency is called dependency injection. What is Dependency Injection(DI)? Class DI Create Objects A objectA = new A() B objectB = new B() www.edureka.co
  • 8. The process of creating an object for some other class and let the class directly using the dependency is called dependency injection. What is Dependency Injection(DI)? Class DI Returns objects to the class www.edureka.co
  • 9. Dependency Injection uses three types of classes. The injector class creates an object of the service class. Then, the injector class injects the object to a client object. What is Dependency Injection(DI)? Client Class Injector Class Service Class www.edureka.co
  • 11. Concept Behind Dependency Injection A class should not configure its dependencies statically but should be configured by some other class from outside. A class should concentrate on fulfilling its responsibilities like the flow of an application, and not on creating objects www.edureka.co
  • 13. Dependencies are provided through a class constructor Injector method injects the dependency to the setter method exposed by the client. Injector uses Interface to provide the dependency to the client class. Constructor Setter Interface www.edureka.co
  • 15. Email Service Class Objects 1. To email address 2. From email address 3. Subject 4. Body www.edureka.co
  • 16. Email Service Class Recreate the Class www.edureka.co
  • 17. Using Dependency Injection Change Objects at run time www.edureka.co
  • 18. Reduction of Boiler plate code Unit Testing is made much easier Application can be easily extended Enables an easy way to interconnect the components 01 02 03 04 www.edureka.co
  • 20. Copyright © 2017, edureka and/or its affiliates. All rights reserved. www.edureka.co