SlideShare a Scribd company logo
6
Most read
11
Most read
13
Most read
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

What's hot (20)

PPTX
Dependency injection presentation
Ahasanul Kalam Akib
 
PPT
Angular 8
Sunil OS
 
PPT
Inheritance in java
Lovely Professional University
 
PDF
Spring Boot
Jaydeep Kale
 
PPT
JDBC Tutorial
Information Technology
 
PPTX
Java Server Pages(jsp)
Manisha Keim
 
PPT
Java collections concept
kumar gaurav
 
PPTX
Java Spring Framework
Mehul Jariwala
 
PPT
Maven Introduction
Sandeep Chawla
 
ODP
Xke spring boot
sourabh aggarwal
 
PDF
Layouts in android
Durai S
 
PDF
Hibernate Presentation
guest11106b
 
PDF
Introduction to java (revised)
Sujit Majety
 
PDF
Servlet and servlet life cycle
Dhruvin Nakrani
 
PPTX
Java Spring
AathikaJava
 
PDF
Spring Boot
koppenolski
 
PDF
REST APIs with Spring
Joshua Long
 
PDF
Exception handling
Anna Pietras
 
PDF
Spring Boot
HongSeong Jeon
 
Dependency injection presentation
Ahasanul Kalam Akib
 
Angular 8
Sunil OS
 
Inheritance in java
Lovely Professional University
 
Spring Boot
Jaydeep Kale
 
JDBC Tutorial
Information Technology
 
Java Server Pages(jsp)
Manisha Keim
 
Java collections concept
kumar gaurav
 
Java Spring Framework
Mehul Jariwala
 
Maven Introduction
Sandeep Chawla
 
Xke spring boot
sourabh aggarwal
 
Layouts in android
Durai S
 
Hibernate Presentation
guest11106b
 
Introduction to java (revised)
Sujit Majety
 
Servlet and servlet life cycle
Dhruvin Nakrani
 
Java Spring
AathikaJava
 
Spring Boot
koppenolski
 
REST APIs with Spring
Joshua Long
 
Exception handling
Anna Pietras
 
Spring Boot
HongSeong Jeon
 

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

PDF
Dependency Injection
Giovanni Scerra ☃
 
PPTX
Dependency Injection in Java Essential for Building Maintainable Projects in ...
Gargee ExcelR
 
PDF
Dependency injection Flash Talk
John Dillick
 
PDF
Dependency injection
Jieyi Wu
 
PPTX
C# Dependency Injection Tutorial | C# Dependency Injection Example | C# Tutor...
Simplilearn
 
PDF
Dependency Injection
Knoldus Inc.
 
PDF
Dependency injection for beginners
Bhushan Mulmule
 
PPT
Dependency injection
Chester Hartin
 
PPTX
Dependency Inversion Principle
Shahriar Hyder
 
PPTX
Di – ioc (ninject)
ZealousysDev
 
PDF
Techlunch - Dependency Injection with Vaadin
Peter Lehto
 
PPTX
Dependency Inversion Principle
Marco Mangia Musardo
 
PPTX
Neoito — Design patterns and depenedency injection
Neoito
 
ODP
Dependency injection explained (Zbigniew Lukasiak)
Ontico
 
PPTX
How to implement dependency injection in c#
Priyank Mittal
 
PPTX
Clean Code II - Dependency Injection
Theo Jungeblut
 
PPTX
Dependency Injection and Autofac
meghantaylor
 
PPTX
Dependency injection
Tyrone Allen
 
PPTX
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
Theo Jungeblut
 
PDF
Real World Dependency Injection - PFCongres 2010
Stephan Hochdörfer
 
Dependency Injection
Giovanni Scerra ☃
 
Dependency Injection in Java Essential for Building Maintainable Projects in ...
Gargee ExcelR
 
Dependency injection Flash Talk
John Dillick
 
Dependency injection
Jieyi Wu
 
C# Dependency Injection Tutorial | C# Dependency Injection Example | C# Tutor...
Simplilearn
 
Dependency Injection
Knoldus Inc.
 
Dependency injection for beginners
Bhushan Mulmule
 
Dependency injection
Chester Hartin
 
Dependency Inversion Principle
Shahriar Hyder
 
Di – ioc (ninject)
ZealousysDev
 
Techlunch - Dependency Injection with Vaadin
Peter Lehto
 
Dependency Inversion Principle
Marco Mangia Musardo
 
Neoito — Design patterns and depenedency injection
Neoito
 
Dependency injection explained (Zbigniew Lukasiak)
Ontico
 
How to implement dependency injection in c#
Priyank Mittal
 
Clean Code II - Dependency Injection
Theo Jungeblut
 
Dependency Injection and Autofac
meghantaylor
 
Dependency injection
Tyrone Allen
 
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
Theo Jungeblut
 
Real World Dependency Injection - PFCongres 2010
Stephan Hochdörfer
 
Ad

More from Edureka! (20)

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

Recently uploaded (20)

PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 

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