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

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

Program With Erik

6 лет назад

74,330 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Tiến Dũng
Tiến Dũng - 05.09.2023 15:05

Thanks sir! I respected your explanation

Ответить
Jorge Gallego
Jorge Gallego - 11.04.2023 02:07

Methods with capital letters... the level of degeneration our society is reaching is alarming.
Anyway, good tutorial!

Ответить
asmodeos666
asmodeos666 - 17.11.2022 13:53

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.

Ответить
Michael Sanders
Michael Sanders - 03.11.2022 02:34

I still don't understand why this is better. "Hey look, we're doing something that will save you one line of code...minus the 2 lines of annotations it adds, but every once in a while it'll save you two seconds.....just forget about the 5 days you've wasted trying to figure out how to structure your program when your normal Java object constructors that perform required initialization of objects fire off multiple times for some unknown reason." I really wish people would stop "saving me time". :D I like how easily I can spit out code to a web server using the controller, but this stuff along with normal java event handling not working and multithreading being done differently...I feel like I'm wasting my life with all the "time savings."

Ответить
bullsbearsfight
bullsbearsfight - 26.06.2022 08:38

u r just awesome with the examples

Ответить
Victor Rosu
Victor Rosu - 24.10.2021 04:56

dude.... you were doing so well, but totally missed the climax. There's no difference in your story between DI and explicitly instantiating one class or the other. You're misleading the noobs...

Ответить
Meri gaand chaato
Meri gaand chaato - 11.07.2021 10:28

Thank you, cleared things for me.

Ответить
Xahmi Yuto
Xahmi Yuto - 26.03.2021 05:00

Best Video on Dependency Injection. TY

Ответить
Murilo
Murilo - 23.12.2020 15:54

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

Ответить
Paul Frischknecht
Paul Frischknecht - 11.12.2020 14:55

Use lombok RequiredArgsConstructor and declare dependencies as private final

Ответить
Paul Frischknecht
Paul Frischknecht - 11.12.2020 14:48

the interface does not have to be a Component

Ответить
go home
go home - 10.12.2020 07:20

thanks

Ответить
xSendiLien
xSendiLien - 10.09.2020 17:32

This is very helpful! Thank you

Ответить
Felix
Felix - 04.06.2020 10:59

Really good!! Thx a lot.
Stay safe.

Ответить
Chenyang Wang
Chenyang Wang - 27.05.2020 11:00

I don't believe you have explained what happens at the background properly.

Ответить
bioman
bioman - 19.05.2020 09:11

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?

Ответить
xyz
xyz - 02.05.2020 03:13

Terrible explanation tbh. Showing a stackoverflow post instead of providing some basics? 5 minutes into the video and nothing related to dependency injection?

Ответить
Joshua Caponong
Joshua Caponong - 11.03.2020 11:55

Am I the only one who finds it irritating that he is starting his method names in capital letters?

Ответить
Anar Xocayev
Anar Xocayev - 12.02.2020 16:33

Very good explanations for Dependency Injection in Spring Boot. thanks

Ответить
geng luan
geng luan - 16.01.2020 09:41

good, helped me a lot.

Ответить
the meter
the meter - 07.01.2020 11:44

useless

Ответить
临高
临高 - 24.12.2019 22:31

I still have no clue how is that useful? doesn't that still instantiate a object of textwriter?(maybe not by your hand but I'm sure it will be instantiate in the background.

Ответить
arunabraham100
arunabraham100 - 16.12.2019 11:37

good tutorial

Ответить
Ibrahim Mohammad
Ibrahim Mohammad - 08.12.2019 21:50

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?

Ответить
shefal shukur
shefal shukur - 02.12.2019 10:17

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

Ответить
Logain Theran
Logain Theran - 27.11.2019 11:39

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.event.ApplicationStartingEvent


why i getting this error?

Ответить
Tapu Mandal
Tapu Mandal - 22.11.2019 02:11

great tutorial

Ответить
satwik burman
satwik burman - 27.09.2019 21:12

Hey Erik this is just amazing. Can you please do a video on the getBeans method?

Ответить
Krishnadas PC
Krishnadas PC - 21.09.2019 11:46

where are the next parts:? What do you mean by @Component?

Ответить
Keyboard Bandit
Keyboard Bandit - 11.09.2019 07:55

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

Ответить
himym910
himym910 - 27.08.2019 18:17

Thank you I found this very useful!

Ответить
Akshita Agarwal
Akshita Agarwal - 20.06.2019 07:11

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

Ответить
Ahmed Saka
Ahmed Saka - 19.06.2019 03:06

It was difficult for me wrapping my head around using the applicationContext.xml to configure the DI

Ответить
Ahmed Saka
Ahmed Saka - 19.06.2019 03:05

Thank a lot Erik, this just made setter injection easier

Ответить
Moe M
Moe M - 14.05.2019 20:34

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

Ответить
Juan Carlos Alvarez
Juan Carlos Alvarez - 11.02.2019 07:27

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

Ответить
LeonTG
LeonTG - 20.12.2018 02:49

You know IntelliJ has auto save right? Also day mode eww

Ответить
Jorge Q. Torres
Jorge Q. Torres - 24.11.2018 00:45

Awesome!

Ответить
Pe Mi
Pe Mi - 02.09.2018 02:30

write methods with first letter Caps wtf?

Ответить
An Nguyen
An Nguyen - 20.08.2018 21:50

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

Ответить
Batuhan Şahan
Batuhan Şahan - 14.07.2018 18:38

Thank you

Ответить
Jhonny Kokos
Jhonny Kokos - 04.04.2018 22:40

thanks a lot! :)

Ответить
e2thee1
e2thee1 - 27.02.2018 10:06

Thanks! Well explained.

Ответить
Franky Vertriest
Franky Vertriest - 08.02.2018 07:41

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

Ответить
kanaltut
kanaltut - 07.02.2018 18:13

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

Ответить