Dependency injection in spring framework: One of the most important concept that you should not miss. Spring dependency injection is one of the most important features that spring provides us. But why it is so popular? What is dependency injection in spring? why do we need it? If you are a beginner, thinking about these questions and looking forward to a fresh start, this is the right place and the right time to get started.

Before you get started with this tutorial you have some dependency as well. Just kidding !! If you are completely new to spring then you need to watch a couple of my other videos which will get you started with spring IOC and dependency injection. Below are the links to those videos.

Spring framework tutorial for beginners with examples in eclipse | Why spring inversion of control?

What is dependency injection in spring [ Getting started ] | Spring framework tutorial for beginners

Ok now we are all set to learn spring’s dependency injection concept and we are going to learn it
step by step. So dependency injection is nothing but injecting the dependency and dependency could be in form of anything. It could be a string or primitive type, It could be a class type or it could be in form of collection.

As I promised we are going to get started with the concept that will cover how we can inject string and primitive based values using spring framework ( injecting literals using spring).

So we have two approaches here to inject a dependency which presents in form of a literal.

The first one is using a setter method. So spring could internally use a setter method to inject the dependencies to a class and this approach is called setter injection.

The second way using what spring can do a dependency injection using a constructor and this is what we called as a constructor injection.

To let spring know that we want to inject the values using a setter method, we have to use a “property" tag and to use a constructor for dependency injection we can use a "constructor-arg”.

so let’s cover everything in detail with this tutorial now.

#dependencyinjection #setterinjection #constructorinjection

Spring dependency injection is also an import feature of Spring IOC which we will be learning from this tutorial onwards with a step by step approach.

for more spring framework training videos and spring important concepts consider subscribing to my channel by clicking the below link.

Stay tuned and like my Facebook page for more.

Music :

credits : -
Adventures by A Himitsu
Creative Commons — Attribution 3.0 Unported— CC BY 3.0
Music released by Argofox
Music provided by Audio Library

intro template :

#spring #injection

Setter & Constructor Injection: Injecting Literal Values | DEPENDENCY Injection In Spring
1.50 GEEK