Dependency Injection Spring: How to use Dependency Injection in Spring Boot

  Рет қаралды 12,734

Dan Vega

Dan Vega

Жыл бұрын

In this tutorial, you will learn what Dependency Injection in Spring is by building a Spring Boot application. I love writing tests because they can expose some issues with how your application is constructed. Follow along as we write some Spring Boot tests that show the problems in our application and how Dependency Injection can solve them. By the end of this video, you will have a good idea of how to use Dependency Injection in your Spring applications.
🔗Resources & Links mentioned in this video:
Spring Dependency Injection Guide: tanzu.vmware.com/developer/gu...
👋🏻Connect with me:
Website: www.danvega.dev
Twitter: / therealdanvega
Github: github.com/danvega
LinkedIn: / danvega
Newsletter: www.danvega/dev/newsletter
SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️

Пікірлер: 28
@OmerFarukAY-ij2xg
@OmerFarukAY-ij2xg 11 күн бұрын
thank you ! it is so awesome that we have created rest api in 8 mins. powerful spring !
@OmerFarukAY-ij2xg
@OmerFarukAY-ij2xg 11 күн бұрын
thank you! waiting excitedly for the new spring project videos
@user-xb9xn1bk5b
@user-xb9xn1bk5b Ай бұрын
As a SpringBoot beginner I found your explanation about DI extremely insightful. Kudos to you !
@theladyjaiproject576
@theladyjaiproject576 Жыл бұрын
I'm a beginning Java programmer, thrown into the deep end of the pool. I had to learn Java, Junit, Mockito, SpringFramework, Maven and a huge application in roughly 2 months. This video was a huge help... Thank you for taking the time to put this together. It will be a constant reference for me.
@samarthurs8000
@samarthurs8000 Жыл бұрын
Absolutely wonderful demo and explanation for DI using SpringBoot. Inversion of Control --> Inverting the Control, i.e., Swapping the Responsibility of Creating/Managing the Object's(Preferably, Usually, a Singleton) lifecycle... Initially, this was done by the Developer (with new() keyword which is ugly and bad practice) but now letting the Spring Container do it for us. Before the DI & IoC, we had to do the hard work. But now the framework does all the hard work. The control is inverted :-D Spring framework scans for the annotations like @Component, @Service, @Repository, @RestController, and so on. Bonus: This video also shows how to use Mockito to write lightweight Unit Tests instead of heavyweight & time-consuming integration tests.
@jonnycoddington1883
@jonnycoddington1883 Жыл бұрын
This is amazing! Really helped solidify Dependency Injection for me. Thanks Dan you are a Spring legend :)
@denischiosa4496
@denischiosa4496 Жыл бұрын
I love how are you using unit tests to test stuff, very useful .
@andrezanlorensi
@andrezanlorensi Жыл бұрын
Thank you for your time making the video about dependency injection that has been immensely helpful to me. Their clear and concise explanation of this complex topic has enabled me to better understand and implement this important software design pattern. Thank you so much for taking the time to share your knowledge and expertise with others.
@aliksargsyan2782
@aliksargsyan2782 Жыл бұрын
Hey Dan, thank you for all of your effort. I stuggle many time to understand the concept of dependency injection, but I learnt a lot by your channel
@DanVega
@DanVega Жыл бұрын
I'm so glad I could be of help Alik.
@DHA508
@DHA508 Жыл бұрын
Thanks Dan Vega for great session
@DanVega
@DanVega Жыл бұрын
You're welcome, Shiva.
@KapilSharma-rp5le
@KapilSharma-rp5le Жыл бұрын
Amazing basics covered
@Arsy1999
@Arsy1999 Жыл бұрын
Excellent work Dan! Really easy to follow your explanations and benefits of Dependency Injection :)
@DanVega
@DanVega Жыл бұрын
Glad you think so! Appreciate the kind words.
@dandendrasingh7326
@dandendrasingh7326 Жыл бұрын
Thank you Dan very nice explanation
@benjamine.ndugga729
@benjamine.ndugga729 Жыл бұрын
Thanks Dan Vega.. love it , we do need more videos on Testing...
@DanVega
@DanVega Жыл бұрын
I completely agree. I believe I saw you in Spring Office Hours yesterday, hope that discussion helped.
@TrueEnroi
@TrueEnroi Жыл бұрын
Thank you
@facu454
@facu454 Жыл бұрын
Hey Dan, thanks a lot for this type of content! It's really enjoyable. Are you planning to make a video about custom error handling in Spring? I'm a begginer in the Spring world and would like to learn about how to manage properly the error responses for a REST api
@DanVega
@DanVega Жыл бұрын
I am now, thanks for the suggestion github.com/danvega/office-hours/discussions/31
@marouaniAymen
@marouaniAymen Жыл бұрын
Thanks for the video. I'm using Spring Boot at work, but for controller tests I prefer applying a MockMvc object and mock service dependency in order to test for various controller HTTP code HttpHTTP EntityResponse codes like 200-400. In my personal point of view, this test approach more accurate and correct that instantiating and invoking the controller's method, because the controller is supposed to return entities "wrapped" in HTTP response codes and we can test the JSON output in case of REST APIs.
@DanVega
@DanVega Жыл бұрын
Thanks for sharing!
@sugoi5240
@sugoi5240 2 ай бұрын
hey do you mind slowing down a bit and take more time explaining the litte things >:D
@alapatisrikanth3412
@alapatisrikanth3412 Жыл бұрын
At 21:00 why are u not calling the slugify method as like this this.service.slugify Instead u calling without "this." Prefix ? Why this works this way?
@DanVega
@DanVega Жыл бұрын
I really didn't need to use this on line 17. this refers to the current object and it's useful when you are trying to be specific when you have arguments of the same name being passed to the constructor. If you omit this Java just expects you mean the current object.
Spring ultimate basics: What are Spring Beans and what is the Spring Container?
16:30
Они убрались очень быстро!
00:40
Аришнев
Рет қаралды 3,3 МЛН
FOOLED THE GUARD🤢
00:54
INO
Рет қаралды 58 МЛН
Must-have gadget for every toilet! 🤩 #gadget
00:27
GiGaZoom
Рет қаралды 6 МЛН
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 750 М.
Learn Dependency Injection and Write Better Code
21:52
Amigoscode
Рет қаралды 167 М.
Spring Security JPA Authentication in Spring Boot
40:04
Dan Vega
Рет қаралды 40 М.
Spring Boot Testing - ** Batteries Included 🔋🔋
41:12
Dan Vega
Рет қаралды 17 М.
Exception Handling in Spring Boot REST API Explained With Demonstration
28:05
Iphone or nokia
0:15
rishton vines😇
Рет қаралды 1,8 МЛН
5 НЕЛЕГАЛЬНЫХ гаджетов, за которые вас посадят
0:59
Кибер Андерсон
Рет қаралды 1,6 МЛН
WWDC 2024 Recap: Is Apple Intelligence Legit?
18:23
Marques Brownlee
Рет қаралды 6 МЛН