All language subtitles for 011 Setter Injection - Overview_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Instructor: In this video,

we're gonna cover setter injection.

Earlier I mentioned the two recommended injection types;

constructor injection and setter injection.

In this video, we'll focus on setter injection.

Setter injection is when we inject dependencies

by calling them setter methods on your class.

Now let's take a look at an Autowiring example.

Here we want to inject a coach implementation,

Spring's gonna scan for components,

and it'll basically say,

"Hey, is there anyone that implements the coach interface?

If so, let's inject them."

For example, the "CricketCoach."

And here's our development process.

So the first thing we'll do is we'll create

the setter methods in our class for injections,

and then we'll configure the dependency injection

using the Autowired Annotation.

All right, let's start with step one

of creating the setter methods in our class for injections.

Here we have our DemoController,

and then we'll have this new setter method here set coach.

And then in step two,

we'll configure the dependency injection

with the Autowired Annotation.

So in our "setCoach" method,

we make use of the Autowired Annotation.

The Spring Framework will perform operations

behind the scenes for you.

Now let's take a look at how

Spring will process your application.

We have our coach interface,

our CricketCoach implementation, and our DemoController,

and we want to inject the dependency

into our DemoController.

Behind the scenes, Spring will create an instance

of the CricketCoach,

it'll create an instance of the DemoController,

and then it'll say demoController.setCoach,

and it'll pass in the coach implementation.

Now we could also inject our dependencies

by calling any method on our class.

We can give it any method name,

simply give the Autowired Annotation.

And here's a coding example of this.

We have our DemoController,

and instead of a traditional setter method,

we could say, "Do some stuff."

We annotate this method as Autowired,

and we can simply give any method name here

for this given method,

and Spring will handle the dependency injection for us.

Okay, great.

So let's kind of step back a bit.

You know, we've saw the different injection types,

constructor injection, setter injection,

and you're probably wondering,

"Well, which injection type should I use?"

Constructor injection, this is the one that you

use when you have required dependencies.

It's generally recommended

by the spring.io development team as the first choice.

And then setter injection,

you should use this when you have optional dependencies.

So if a dependency is not provided,

then your app can provide some reasonable default logic.

So that's the basic guidance

that the Spring Development Team provides

as far as which injection type to use.

Okay, this is all really good stuff here.

Let's go ahead and move into our IDE,

and let's write some code.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.