Dependency Injection in Spring boot | With Advantages and Disadvantages

Поделиться
HTML-код
  • Опубликовано: 26 ноя 2024

Комментарии • 85

  • @darksidekiller5300
    @darksidekiller5300 6 месяцев назад +9

    This was hands down the best Dependency Injection on RUclips, I've seen this topic from literally every other RUclipsr and no teaches with this much simplicity and depth...
    Can not thank you enough for providing this level of quality!

  • @yashgupta7220
    @yashgupta7220 5 месяцев назад +4

    Bro, you're crazy!!
    You made the Spring DAMN easy!!
    Love your content

  • @SoftwareEngineer2-ug5fl
    @SoftwareEngineer2-ug5fl 6 месяцев назад +6

    Awesome video. One request to all viewers, please ask more and more questions in the comment section. It will help others and specially beginner to get more clear view of topics.

    • @nowitspk
      @nowitspk 4 месяца назад

      Sounds good. Will comment here if have any doubts

  • @mariyajoshkatteboina8749
    @mariyajoshkatteboina8749 5 месяцев назад +2

    Wow, You are a great teacher as well, You way of teaching makes concepts easy, My humble reaquest to you sir, Please do make more videos on springboot it will help us, please!

  • @chandangupta1822
    @chandangupta1822 5 месяцев назад

    This is an amazing lecture, far better than all the Udemy courses on Spring Boot. Please complete the Spring Boot series. btw this series is not available on Udemy business.

  • @in_tyler_we_trust
    @in_tyler_we_trust 6 месяцев назад +2

    Sir please continue this greatest spring boot playlist and hope to get more videos frequently...

  • @mynksrswt483
    @mynksrswt483 7 месяцев назад +14

    For those who think they mastered this video after one watch, you might be underestimating things! Take a couple more views to really soak it all in. Trust me, giving it a few extra rounds now could save you from a major 'uh-oh' moment in production later. So buckle up and get comfy with this video! By the way, awesome job on the video, @shrayansh

    • @prof_as
      @prof_as 7 месяцев назад +1

      thanks man, was thinking like this only. after i watched again i realized it.

    • @Nishi-Tiwari
      @Nishi-Tiwari 14 дней назад

      @@prof_as I too need to re-listen to this lecture. Honestly I agree with the people in the comment section that he explains concepts in an easy manner. But these are actually complex topics.

  • @raushankumargupta7018
    @raushankumargupta7018 Месяц назад +1

    Perfect explanation Saransh✨ thanks

  • @JackSparrow-t3x
    @JackSparrow-t3x Месяц назад +1

    next level explaination Thank you!!!

  • @eshwarsai5027
    @eshwarsai5027 5 месяцев назад

    Excellent and amazing explanation. Big Thanks ........for the video

  • @motivation_hubPJ
    @motivation_hubPJ 7 месяцев назад +9

    hi can you please share some open source java projects links which are nicely written web apps (follows solids & desgin patterns ) or which industry teams look for standardisation and reference. I know there are many but can't figure out the quality .

  • @VenkatReddy-qi6ec
    @VenkatReddy-qi6ec 5 месяцев назад

    thank you so much for your valuable teaching, hope you will complete full stack java developer course,
    and please upload this complete spring boot course in udemy.
    good bless you bro.

  • @rahulas721
    @rahulas721 7 месяцев назад +6

    In the previous video you mentioned we can use @Bean to tell spring what values to pass in the constructor when creating the object.
    So suppose we have the following User constructor :
    @Autowired
    public User( String name, IOrder order )
    The order object is injected by using constructor injection. But how will spring know what value of name it has to pass?
    Do we need to define it using @Bean ( if yes then how will the code look like? ) or is there any other method?

    • @in_tyler_we_trust
      @in_tyler_we_trust 6 месяцев назад

      Did you find the answer to your problem?

    • @cozitsyash1301
      @cozitsyash1301 6 месяцев назад

      We need to create a bean for String as well ..

    • @yashrdoshi
      @yashrdoshi 28 дней назад

      I think something like this would work (Not tested below code)
      @Configuration
      class Config{
      @Autowired
      Order order;
      @Bean
      public User createUser(){
      return new User("sampleName",order);
      }
      }

  • @AnkitRawat-bi1rj
    @AnkitRawat-bi1rj 4 месяца назад +1

    @Shreyansh , at 20:30 i think using constructor injection also ensures that it first resolve all the injected class by creating the object of them and after that it initialize object of that class itself, as i can see in the screenshot , the example...first "Order Initialized" then "User Initialized" , please correct if i am wrong?

  • @ashwanikumarpatel7460
    @ashwanikumarpatel7460 7 месяцев назад +1

    In production i always use @Service instead of @component, @Bean …when it’s initialised ?

  • @nileshpawar5150
    @nileshpawar5150 7 месяцев назад +2

    Very nicely explained

  • @baburaomulaparthi4531
    @baburaomulaparthi4531 7 месяцев назад +1

    Thanks bro
    Very Nice explanation

  • @Randomvideo2610
    @Randomvideo2610 7 месяцев назад +4

    for setter dependency injection it will inject dependency at startup time or we have to call setter function?

    • @ConceptandCoding
      @ConceptandCoding  7 месяцев назад +1

      at application startup, if its not marked Lazy

  • @sahilgarg3460
    @sahilgarg3460 7 месяцев назад

    Hi Shrayansh, can you reply on below 2 query?
    1. As a Java dev who is responsible for adding cicd in project in corporate
    2. In production, usually how logs are monitored

  • @vedantgore196
    @vedantgore196 Месяц назад

    Hey Shreyansh, I have one doubt, you said that using Field Injection we will have chances of Null Pointer Exception, but how is it possible? Since @Autowired will first find the bean of Order type and if not there then it will create one bean. So if it is creating then how come it will give NullPointerException?

  • @naveentmyug
    @naveentmyug 6 месяцев назад +1

    At 14:06, while creating new object for USER class, why we got NPE for order, as while initialization ORDER is being injected in user parameters,

    • @suryabala6369
      @suryabala6369 6 месяцев назад +1

      Hi @naveentmyug did you get the answer for this?

    • @naveentmyug
      @naveentmyug 6 месяцев назад

      @@suryabala6369 nopes

    • @ConceptandCoding
      @ConceptandCoding  6 месяцев назад +1

      hi, if you are creating USER object using NEW , how ORDER member variable will get initialized.
      as its marked as AUTOWIRED. And spring will not initialize it automatically.
      there is Already 1 USER Bean present, which was initialized by Spring, but when you are creating using NEW, its creating new object.
      hope that clarifies.

    • @naveentmyug
      @naveentmyug 6 месяцев назад

      @@ConceptandCoding yes, now I am good with it. Thanks

  • @rohiteshupadhyay7165
    @rohiteshupadhyay7165 4 месяца назад

    Will it be possible If you can provide link of the presentation you created in the description?

  • @harshgarg0906
    @harshgarg0906 6 месяцев назад +2

    I have one question
    Suppose I have an Order Interface and I have two implementation i.e OnlineOrder and OfflineOrder
    Using the @Qualifier and @Primary I can decide at the start of the tomcat which one to use
    My question here is that Suppose when the request hit my controller and in the @PathVariable I put online then I need to use the OnlineOrder and if in @PathVariable I put the offline then I need to use OfflineOrder . So how at the runtime I can tell the Spring DI to use the desired bean depending on what is coming as Input . Is there a way to do this?

    • @ConceptandCoding
      @ConceptandCoding  6 месяцев назад

      yea you can do it. For that you need to use @Bean
      in that method you can put custom logic (if else condition) and return the object of Online or Offline which you required

    • @harshgarg0906
      @harshgarg0906 6 месяцев назад

      @@ConceptandCoding @Bean will also going to create the object at deployment time only
      and if i write the if else in controller method then Are we breaking the SOLID principal ?

    • @ConceptandCoding
      @ConceptandCoding  6 месяцев назад

      no, it will not break.
      And Today its how done in Live application too.
      choose object dynamically based on some input

    • @cozitsyash1301
      @cozitsyash1301 6 месяцев назад

      Great doubt bro

  • @nishaaa_maurya
    @nishaaa_maurya 6 месяцев назад

    This concludes the Spring Boot tutorial. Are there additional tutorials planned for the future?

  • @captain_fun29
    @captain_fun29 6 месяцев назад +1

    Hi Shrayansh, I have purchased the membership. The notes are visible for now, but I read in the perks that the notes will have 2 years of expiry. So, after one month, when I am no longer a member, how will I be able to access the notes?

  • @Suyashlike
    @Suyashlike 7 месяцев назад

    Hi Sheyansh, very nice video. One confusion I have is regarding last example in the video. Had the "Order" been a base class rather an interface, did we have to use primary or qualifier annotation? And by using these primary or qualifer annotation are we not breaking dependency inversion rule as we are depending on 1 concrete implementation out of many?

    • @ConceptandCoding
      @ConceptandCoding  7 месяцев назад +1

      good question buddy.
      Using @Qualifer, we do tell Spring to inject particular concrete class. But it does not break Dependency inversion principle. As our class still uses Abstraction only.
      But since we are not using @Bean and instead relying on @Primary or @Qualifier which tell spring, which dependency to use, when more than 1 bean present with same interface. (so its more of, that we are providing input to Spring, how to solve the dependency).
      But you can understand it better, if you try to use @Bean annotation in config class. And from there, you can control, which Bean to return whether OnlineOrder or OfflineOrder whenever Order Bean is requested. So now you will see that our class still follows dependency inversion, as no matter what concrete class object you will add, it will work.
      Hope that clarifies.

  • @manojkar7110
    @manojkar7110 4 месяца назад

    @shreyansh at time 19:31 the user class doesn't have any default constructor and we have @component added , the how is the object getting created?

  • @kartikkaushik4743
    @kartikkaushik4743 Месяц назад

    Hi Shreyansh the RUclips vedio is showing private and I am not able to watch it out

  • @ramakotireddynagireddy8913
    @ramakotireddynagireddy8913 6 дней назад +1

    Please share documents what ever explained

  • @randomguy4822
    @randomguy4822 7 месяцев назад

    Hi Shreyansh , i had one question, till when are you planning to cover up all the lectures , like by what month will all aspects be covered up

  • @raghutata747
    @raghutata747 7 месяцев назад

    Hello Shryansh,
    Can we get more working examples of Dependency Injection.. May be used in some LLD Question, that will be even more helpful.

  • @shreyojitdas9333
    @shreyojitdas9333 6 месяцев назад

    sir whats next after this playlist?

  • @jagadeeshp1163
    @jagadeeshp1163 4 месяца назад

    Can we please get a playlist on microservices

  • @ArnavKircha
    @ArnavKircha 6 месяцев назад +1

    Best videos !!!

  • @shyamsoni5389
    @shyamsoni5389 4 месяца назад +1

    awesome video

  • @dwivedishashank9
    @dwivedishashank9 6 месяцев назад

    22:01 - Not getting any exception when multiple constructors present without @Autowired and compile error is to be observed. Did anyone noticed this?

  • @narayangoyal295
    @narayangoyal295 7 месяцев назад

    Bhaiya , i love your videos, it will be very helpfull if you make some videos on crypotography
    i really need that

    • @ConceptandCoding
      @ConceptandCoding  7 месяцев назад

      hi pls check this one :
      ruclips.net/video/GtSUeAkPEP0/видео.html

  • @NiharikaPalamala
    @NiharikaPalamala 3 месяца назад

    Hi why is this video suddenly a member only content

  • @devgupta2040
    @devgupta2040 2 месяца назад

    manual instantiation should be avoided in spring, right? if we do not instatiate the user class manually, then npe will not be raised. please correct me if i am wrong.

    • @ConceptandCoding
      @ConceptandCoding  2 месяца назад +1

      right, manually we should not create, but sometimes we do where we don’t need bean creation

  • @pushpakkatkar8604
    @pushpakkatkar8604 3 месяца назад

    Hi Shreyansh
    I am getting some issue while joining this channel, my payment is failing can you help me with this. I have tried several times now

  • @shwetanksudhanshu4383
    @shwetanksudhanshu4383 4 месяца назад

    Do we need @Autowired when doing setter injection ?

    • @ConceptandCoding
      @ConceptandCoding  4 месяца назад +1

      Yes, you need to use @Autowired on the setter method to enable setter injection in Spring. This annotation tells Spring to inject the dependency when it calls the setter method.

  • @tarunprahladka3230
    @tarunprahladka3230 7 месяцев назад

    when we get the next videos for the playlist?

  • @Werewolf5684
    @Werewolf5684 7 месяцев назад

    Q1. @Qualifier("OnlineOrderName") : this is we are hard coding in the application write? let say we want now object of Offline Order in our User Object then how can we change that?
    Q2. Can we write this if we have multiple dependency in User class let say Order and Invoice
    @Autowired
    public User(Order order, Invoice invoice) {
    this.order = order;
    this.invoice = invoice;
    }

    • @prashantgupta6093
      @prashantgupta6093 3 месяца назад

      We can use PostConstruct if you have not set the Order as final, but that's not the best practice to follow.

  • @raghutata747
    @raghutata747 7 месяцев назад

    Hello Shryansh,
    When will the next videos be uploaded?

    • @ConceptandCoding
      @ConceptandCoding  7 месяцев назад

      i will work on this weekend, by next week

    • @raghutata747
      @raghutata747 7 месяцев назад

      @@ConceptandCoding Hello sir, Thank u so much. Please upload in bulk if possible. This is really helping me a lot, specially the way you cover interview expected questions. Exactly those questions are only asked.

  • @Cricket-xs1vc
    @Cricket-xs1vc 7 месяцев назад

    Hi Shreyansh, I cannot find the notes for java playlist

    • @ConceptandCoding
      @ConceptandCoding  7 месяцев назад

      pls check member community post section buddy

    • @Cricket-xs1vc
      @Cricket-xs1vc 7 месяцев назад

      @@ConceptandCoding got the notes thanks Shreyansh

  • @ericsiddiq7634
    @ericsiddiq7634 7 месяцев назад +1

    Thanks

  • @surajsri248
    @surajsri248 6 месяцев назад

    Can we inject more than one constructor in a class

    • @ConceptandCoding
      @ConceptandCoding  6 месяцев назад

      Yes, internally spring will pick the constructor with most dependency resolved.
      Try it out

  • @bilalshahid9714
    @bilalshahid9714 2 месяца назад

    How to become member? I see no join option

    • @ConceptandCoding
      @ConceptandCoding  2 месяца назад

      @@bilalshahid9714 at home page there should be join button or pls check description section

  • @hamayonwazir9748
    @hamayonwazir9748 7 месяцев назад

    Hello how to get a membership of your channel being from pakistan?

    • @ConceptandCoding
      @ConceptandCoding  7 месяцев назад +1

      pls check description section, you will find the joining link buddy.

  • @DevanshChiluka
    @DevanshChiluka 7 месяцев назад +1

  • @kashishgarg1008
    @kashishgarg1008 7 месяцев назад

    dmp main 1 lakh ki internship mil rhi hai, video bana do

  • @fakegamer9025
    @fakegamer9025 2 месяца назад

    Bro why u did this?
    you are saying to watch #5 video, and that is Member-Only video, how will i see that, entire flow is broken now, i have watched all the other playlists... its really hard to find single channel with entire content... 😭