All language subtitles for 013 Field Injection_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
vi Vietnamese Download
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Instructor: In this video,

we'll cover field injection

with Annotations and Autowiring.

Now, as I discussed earlier,

there are different Spring injection types,

and so there are the types that are recommended

by the spring.io development team.

That's constructor injection for required dependencies,

setter injection for optional dependencies.

Now, here's an injection type that's not recommended

by the spring.io development team

and that's field injection.

And field injection is no longer cool.

So in the early days,

field injection was very popular on Spring projects

but in recent years it has fallen out of favor.

And why is that?

Because in general, it makes the code harder to unit test.

Now, as a result, the spring.io team

does not recommend field injection,

however, you'll still see it being used on legacy projects,

and also you'll see it being used

in a lot of old blog posts on the internet,

and even in previous versions of this course,

I actually used field injection,

but now with modern times here,

removing the useless field injection,

and instead making use of construction or setter injection,

but I'll still show you a little quick example here

of using field injection just in case you encounter it

on some of your legacy projects.

Field injection is the idea of injecting in dependencies

by setting the values on your class directly,

even on private fields,

and this is accomplished by using Java Reflection.

So in step one, you simply configure

the dependency injection using the Autowired Annotation,

and so here's a code example on our DemoController.

Notice here we have this field private Coach, myCoach,

and we give the Autowired Annotation,

and behind the scenes,

Spring will inject a given Coach implementation,

and it'll do it behind the scenes even on a private field.

It'll automatically or directly set it on this controller,

and notice here, there's no need for constructors,

there's no need for setters,

Spring will set the field directly.

However, like I mentioned,

field injection is not recommended

by the spring.io development team

because it makes the code harder to unit test.

All right, so that's field injection.

So I wanted to show it to you

just in case you encounter it

on some of your legacy projects.

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