Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Instructor: Let's go ahead and take care
of our normal housekeeping;
stopping all apps and closing all windows.
And I'll move in here into my file system
into my dev-spring-boot directory.
And into my O2 spring boot core.
And then I'll copy paste our O2 component
scanning directory here and I'll simply rename it
and give it a new name.
And I'll call it 03 setter-injection.
Now go ahead and open up this project in IntelliJ.
And what I'd like to do first is do a rebuild
on the project.
This'll help with auto reloading of spring boot dev tools.
And step one will create the setter method
in our class for injections.
And step two will configure the dependency
with the Autowired annotation.
Let's go ahead and move into our demo controller.
I'll expand my window for a second.
And what I wanna do is delete some of the previous code.
So where we had our constructor injection
I wanna delete this code
because now we're gonna make use of setter injection.
I'll set up Autowired annotation
and I'll create this setter method setCoach
and then I make the appropriate assignments inside
of this method.
Okay, so we have the basic things
in place here for setter injection for our demo controller.
And now let me swing over to my spring boot application.
I'm gonna delete the previous code I had
for all of the scanned based packages.
Just kind of get rid of it for right now.
We already have backups of it
in some of the other directories.
And great so that's all cleaned up now.
Now let's go ahead and run our application.
And our application is up and running.
Just swing over to our browser and we go
to our local hosts 8080/dailyworkout.
And our app's gonna work the same.
We're gonna get the output here
for this cricket coach practice fast bowling for 15 minutes.
So we know that our application is actually
performing the setter injection at this point.
Now what I'd like to do is move in here
and just change this method real quick
just to make the text a little bit different.
Just do a quick save on it should reload for us.
And then swinging back over into our browser reloading
we should see the new output.
So that's our recent update that we have here.
Okay, good.
And now what I'd like to do
in our demo controller is actually make a modification.
So instead of using a traditional setter method,
I want to just give it any method name here.
So instead of set coach, I'll give any method name
I'll call it, I don't know, doSomeStuff.
You can give whatever name you'd like here.
The fact that this method is annotated
with the auto wired annotation
then spring will use this for dependency injection.
Alrighty, so if we save that accordingly
come back over here.
Reload. And our app works just fine.
So we're getting the message.
So we know that our app is working
with injection, based on any method name that we provide.
And again, because of that auto wired annotation.
Just do a quick little update on the method here,
and okay, great.
So we're getting the latest and greatest here.
So this part is working out as desired.
Now what I'd like to do is kind of just swing back
and just put it back to the traditional set of methods
just to make it straightforward
and easy to read and understandable.
Instead of do some stuff, I'll call it set coach
just to, yeah, that's exactly what we're doing,
we're setting a coach
and great.
So that's in place. We're good to go.
We're all set up.
So that's a quick example there
of using setter injection with spring.
Good job.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.