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

Поділитися
Вставка
  • Опубліковано 15 лис 2024

КОМЕНТАРІ • 31

  • @samarthurs8000
    @samarthurs8000 Рік тому +1

    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.

  • @LeoLawrence-b7u
    @LeoLawrence-b7u 6 місяців тому

    As a SpringBoot beginner I found your explanation about DI extremely insightful. Kudos to you !

  • @theladyjaiproject576
    @theladyjaiproject576 Рік тому +4

    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.

  • @OmerFarukAY-ij2xg
    @OmerFarukAY-ij2xg 5 місяців тому

    thank you ! it is so awesome that we have created rest api in 8 mins. powerful spring !

  • @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.

  • @OmerFarukAY-ij2xg
    @OmerFarukAY-ij2xg 5 місяців тому

    thank you! waiting excitedly for the new spring project videos

  • @denischiosa4496
    @denischiosa4496 2 роки тому

    I love how are you using unit tests to test stuff, very useful .

  • @aliksargsyan2782
    @aliksargsyan2782 2 роки тому

    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.

  • @jonnycoddington1883
    @jonnycoddington1883 Рік тому +1

    This is amazing! Really helped solidify Dependency Injection for me. Thanks Dan you are a Spring legend :)

  • @programtin
    @programtin 4 місяці тому

    Absolutely wonderful

  • @benjamine.ndugga729
    @benjamine.ndugga729 2 роки тому +1

    Thanks Dan Vega.. love it , we do need more videos on Testing...

    • @DanVega
      @DanVega  2 роки тому +1

      I completely agree. I believe I saw you in Spring Office Hours yesterday, hope that discussion helped.

  • @DHA508
    @DHA508 2 роки тому +2

    Thanks Dan Vega for great session

    • @DanVega
      @DanVega  2 роки тому

      You're welcome, Shiva.

  • @timirthelame
    @timirthelame 2 місяці тому

    I actually came into this video to see what is the best practice of DI in Spring, but I learned more than I expected :) Is it safely to say "Constructor Injection is the best practice" Dan?

  • @marouaniAymen
    @marouaniAymen 2 роки тому +1

    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  2 роки тому

      Thanks for sharing!

  • @Arsy1999
    @Arsy1999 2 роки тому

    Excellent work Dan!
    Really easy to follow your explanations and benefits of Dependency Injection :)

    • @DanVega
      @DanVega  2 роки тому

      Glad you think so! Appreciate the kind words.

  • @dandendrasingh7326
    @dandendrasingh7326 Рік тому

    Thank you Dan very nice explanation

  • @KapilSharma-rp5le
    @KapilSharma-rp5le Рік тому

    Amazing basics covered

  • @facu454
    @facu454 2 роки тому +2

    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  2 роки тому +1

      I am now, thanks for the suggestion github.com/danvega/office-hours/discussions/31

  • @TrueEnroi
    @TrueEnroi 2 роки тому

    Thank you

  • @sugoi5240
    @sugoi5240 7 місяців тому +1

    hey do you mind slowing down a bit and take more time explaining the litte things >:D

  • @alapatisrikanth3412
    @alapatisrikanth3412 2 роки тому +1

    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  2 роки тому +2

      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.