Spring Boot Dependency Injection - What Is It? Tutorial and Example

preview_player
Показать описание
In this video we look at dependency injection in Spring. We'll talk about qualifiers, autowired and interface. Stay all the way to the end to find out how it all works and learn about my giveaway!

___

LEARNING TO CODE? CHECK OUT THESE COURSES! (SOME ARE AFFILIATE)

___

___

___

Links

___

Рекомендации по теме
Комментарии
Автор

It's better to use constructor injection for testability. Your methodnames also need to start with a small letter

frankyvertriest
Автор

This video was gold! I was beginning to think I would never understand autowiring. Thank you!

akshitaagarwal
Автор

Awesome explanation of dependency Injection! Ultimately I got some source where explanation is clear without confusion! Thank you.

shefalshukur
Автор

Thanks for explaining this rather simply, but I think the last part of the video counters the use of DI completely. If you use an abstraction in a class but you need need to provide a qualifier with it that matches the one of the implementation you want then it basically is equivalent as new-ing the implementation up in the class directly. Your class is now directly tied to the implementation through its qualifier which is precisely what we try to avoid with DI and IoC. The class shouldn't be responsible of this, it should be configured elsewhere.

asmodeos
Автор

Thanks sir! I respected your explanation

DunTrann
Автор

Best Video on Dependency Injection. TY

xahmiyuto
Автор

Very good explanations for Dependency Injection in Spring Boot. thanks

anar.xocayev
Автор

This is counterintuitive. Why do you decorate a field with @Autowired and then assign a value to it in the constructor anyway? If it should be autowired then why do you wire it yourself? Also I wouldn't call wireing a field dependency-injection. It's rather dependency-hacking. How would you override this for testing when it's virtually a hardcoded dependency?

this-is-bioman
Автор

Great video man! thanks for taking the time to show us.
Cheers from Guadalajara

Kalashnikova
Автор

Hey Erik, thanks for this post! Great example for the @Autowired and @Qualifier!

moem
Автор

Man... this is by far the easiest and cleanest explanation I found on Youtube regarding dependency injection. Go Erik..!

devolee
Автор

Youre a great communicator.
Thanks 👍🏾

MrMakemusicmike
Автор

Great video ! Solved a lot of my struggles with dependency injection.

murilo.g.t
Автор

Still at the end of video with two implementation you need qualifier which induces tightly coupleness

jainamshah
Автор

Thanks, Erik, nice lesson! Keep them coming. :)

stefan
Автор

Hey Erik, what do i do if i have a Component that has a parameter in its constructor? For example a String. How can i account for this paramter in my RestController class when i AutoWire the Component?

TheFailCrewTM
Автор

Is there any video series about spring boot from the beginning? On YouTube

hitendrasonkushare
Автор

Thank you for the video. Can you please create a video on how to pull data from sql and display on the UI?

AnNguyen-dqmn
Автор

Thank you for this! Makes so much more sense now!

keyboardbandit
Автор

Use lombok RequiredArgsConstructor and declare dependencies as private final

paulfrischknecht