Decoding Spring Bean scopes | Hands-On | Spring interview questions and answers for experienced

Поділитися
Вставка
  • Опубліковано 5 сер 2024
  • In this video, we will talk about spring bean scopes. This is one of the hot topics for the spring interview as well. So today, I will give you an in-depth deep dive on the 6 different bean scopes that we have.
    We will explore various beans scopes like singleton, prototype, request, session, application, and WebSocket. Not only I will tell you about the uses of it, but also I will make you familiar with various spring interview questions.
    This bean scope in the spring framework tutorial also covers a comparison between various scopes.
    For example:
    Singleton vs Prototype scope,
    Request vs Session scope,
    Request Vs Prototype scope and,
    Singleton vs Application scope.
    Note that these scopes comparison questions are popular spring interview questions both in the freshers and experienced category.
    Prerequisite :
    [ spring framework tutorial for beginners with examples ]
    Spring Core basics :
    • Spring framework tutor...
    Spring MVC basics :
    • Spring MVC course intr...
    Spring MVC Java-based configuration :
    • Spring MVC Java Based ...
    Course contents :
    spring bean scopes
    Video Map: ⏱️TIMESTAMPS⏱️
    Introduction: 00:00:00
    [ The default scope of the bean ]
    Singleton scoped bean: 00:10:16
    Introducing @Scope spring annotation: 00:19:04
    How to define Singleton scoped bean [Animations]: 00:20:15
    Prototype scoped bean[example]: 00:21:53
    [When to use singleton and prototype scope in spring]
    Singleton vs prototype tricky question: 00:30:51
    Bean Initialization (Singleton vs Prototype): 00:38:52
    Injecting prototype bean inside a singleton bean: 00:47:00
    singleton bean with prototype dependencies: 00:49:36
    Injecting prototype scoped bean inside a singleton scoped bean Problem: 00:51:30
    spring aop scoped proxy: 00:58:34
    Introducing Spring CGLIB/ Proxy: 01:06:30
    Singleton Scoped bean Vs GOF singleton design pattern: 01:26:40
    singleton scope vs singleton pattern (Interview FAQ ): 01:37:30
    @LookUp walkthrough: 01:13:37
    lookup (abstract) method injection in spring: 01:20:00
    @LookUp annotation homework/ Assignment : 01:25:53
    Spring web-aware bean scopes: 01:38:29
    Spring bean scope Assignment 02- 01:42:24
    [Request scope in spring]
    Request bean scope: 01:43:29
    The standard way to define request scope: 02:10:29
    Session bean scope: 02:11:50
    Request Vs Prototype scoped bean: 02:19:29
    Application scope theory: 02:25:39
    Application scoped bean example: 02:41:32
    Websocket bean scope: 03:14:29
    This topic is popular for the “ spring interview questions and answers for experienced " and "spring interview questions and answers for freshers“ category. Make sure to explore every scenario that I have covered in this video. Make sure these are the same bean scopes that we use in spring boot as well.
    #SpringBeanScopes #SpringFramework #SpringInterview
    ===================
    For more courses visit
    www.seleniumexpress.com
    Any time you are getting stuck with issues, Feel free to ask for support.
    You can send mail to seleniumexpress@gmail.com
    you can ping me on my Facebook page.
    / seleniumexpress
    Make sure to join my private Facebook page (Ask me here)
    “SeleniumExpress - Support"
    / 187000222361579
    you can ask for support in my website forum
    www.seleniumexpress.com
    Subscribe to my youtube channel
    / @seleniumexpress
    Follow me on Insta
    / selenium_express
    Music :
    -----------
    credits: -
    (channel intro)
    Adventures by A Himitsu / a-himitsu
    Creative Commons - Attribution 3.0 Unported- CC BY 3.0
    creativecommons.org/licenses/b...
    Music released by Argofox • A Himitsu - Adventures...
    Music provided by Audio Library • Adventures - A Himitsu...

КОМЕНТАРІ • 139

  • @SeleniumExpress
    @SeleniumExpress  3 роки тому +25

    Once you are done watching
    Take this quiz :
    www.seleniumexpress.com/quizzes/spring-bean-scopes/
    See you guys soon !!

    • @basavaraj2065
      @basavaraj2065 3 роки тому

      When we can do everything using Annotation's what is the need of using XML's ?

    • @intrdaytrader230
      @intrdaytrader230 3 роки тому

      You looks like junior ntr !

    • @smishra9691
      @smishra9691 3 роки тому

      And i secure 9 out of 9 score yeah today what i am in concept of scope all bcz of you sir😊

    • @yoshitamahajan353
      @yoshitamahajan353 3 роки тому +1

      Hi I was unable to view my score post giving the quiz..

    • @sheejak3077
      @sheejak3077 3 роки тому +1

      How to get the score?

  • @deepakmodi10
    @deepakmodi10 3 роки тому +26

    I took leave today and watched 3 videos and spent more than 6 hours. Worth watching and utilized the time very well. Keep up the great work. Learnt a lot. Also your explanation is simple and clear to understand.

  • @thumarmitesh6559
    @thumarmitesh6559 3 роки тому +4

    I didn't know I could sit and watch a 3 hr YT video studying, thank you so much

  • @wfwf7645
    @wfwf7645 3 роки тому +7

    Without finishing the entire video, I am going to press Like first. In my personal opinion, you have the best explanations on the topic of Spring amongst all the youtubers on UA-cam! Thanks for teaching us and sharing your knowledge with us, you rock!!

  • @thiyamybabygirl2144
    @thiyamybabygirl2144 3 роки тому +10

    No one can give such a useful videos with zero cost. Thanks abhilash.

  • @muthunarendran409
    @muthunarendran409 3 роки тому

    As usual ! Simple , Clean and Crystal Clear!!

  • @abhinandanjhansi5
    @abhinandanjhansi5 3 роки тому +1

    Bro, you are the best!!! One of the best tutorials I have ever gone through.. you took so much care of your audience who is following!! Best best best!! Thank you very much..

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

    Thank you very much for that video. I was looking for hours to a post or video that explains those concepts in details and this is the only one I found.

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

    Love your style of teaching, passion and how you give real work example to make the concept undertandable.

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

    BEST VIDEOS for SPRING MVC ! Thank you so much for your hardwork :)

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

    So intuitive, and I just love the mode of delivery

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

    nobody could ever made spring bean scope so easy, at least to me!!! Really enjoyed it!

  • @vivekverma6676
    @vivekverma6676 3 роки тому

    Best Video on spring bean scope. Every second of this video is worth it!!! Thanks a lot Abhilash.

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

    Very intuitive and well explained. It's 2 AM IST and I am still awake and just now finished the video. It's very interesting to learn things in simple words. Thanks for uploading such a great video. You are one of the best teacher on UA-cam.

  • @PrityKumari-bk7dp
    @PrityKumari-bk7dp 2 роки тому

    This is an excellent explanation, I never had such an amazing explanation on spring bean scopes, Please keep doing it,Thanks a lot :)

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

    Awesome Video Abhilash, no one will explain the bean scopes in such detailed manner. Hats Off to you

  • @priyasahu5295
    @priyasahu5295 3 роки тому

    really awesome.God bless you always as you helping so many people by doing this... :) You are great

  • @Patilnitin14
    @Patilnitin14 3 роки тому

    Thank you very much for this video. Never got bored of 3 hrs lecture. Waiting for web socket example.

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

    What a wonderful explanation! Awesome Job

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

    Thanks for all your lectures and giving us deep insight to java concepts.

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

    Now i have fully understand entire scope and their usage.tq brother providing crisp and clear

  • @rohitsharma-xt8qe
    @rohitsharma-xt8qe 3 роки тому

    Awesome content and representation. Appreciate your hard work.

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

    Great content bro!🙌🏻 Thanks alot!🙏🏻

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

    thank you very much for the great and simple explanation

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

    Hats off to you....for sharing this wonderful knowledge free

  • @priyasharma-ss5fb
    @priyasharma-ss5fb 3 роки тому

    You made a wonderful video. Explanation is quite simple and easy to understand

  • @aswinkamath1395
    @aswinkamath1395 3 роки тому

    Good explanation of concepts. Please come up with more Spring Framework tutorials.

  • @nikita-shamrai
    @nikita-shamrai Рік тому

    Great explanation, thank you!

  • @SanjayKumar-by6oc
    @SanjayKumar-by6oc 2 роки тому

    Great abhilas! Keep up the good work!!

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

    Amazing video!!!

  • @dharanivelvicky6057
    @dharanivelvicky6057 3 роки тому

    Your way of teaching is awesome

  • @ramanandkumar7780
    @ramanandkumar7780 3 роки тому

    Very nice explanation...you have covered a very important question that is asked frequently

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

    Great job!!!

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

    Thanks a lot for sharing.. 👏

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

    Thank you so much Abhilash for the great video. Learned a lot from your videos.. 😇

  • @Rahulverma-hl1hf
    @Rahulverma-hl1hf 3 роки тому

    Loved your videos. I have no words to thank you..have a request to please come up with spring boot/microservice

  • @mantookumar2157
    @mantookumar2157 3 роки тому

    Thanks, really helpful

  • @Ramesh-re4eu
    @Ramesh-re4eu Рік тому

    The background score in the middle was damn good sir it feels soo refreshing..

  • @weabits
    @weabits 9 місяців тому

    Hello from Kazakhstan. 16.10.2023 10:53 PM
    Thank you very much for the video, especially this one.
    I learned and understood a lot thanks to you, good luck!

    • @aibardulatov
      @aibardulatov 5 місяців тому

      me same, buddy. This guy definitely best teacher on UA-cam, I've ever seen.

  • @aneksingh4496
    @aneksingh4496 6 місяців тому

    wow ...great analysis ...very informative video

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

    Hello Bro, U r genius. Hats up to your explanation...god bless u bro...

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

    Sir, superb, very clear explanation, thanks a lot.

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

    Worth watching 👍🙏

  • @smishra9691
    @smishra9691 3 роки тому

    Superb finally i completed 3 hrs video within 8 hrs but feel very positive thanks sir ... please upload 2nd part of scope websocket and use of scope where to use what.. am waiting . . Lots of respect from odisha sir😊

  • @rahulwarule6377
    @rahulwarule6377 3 роки тому

    It's really helpful, tnx Abhilash 😊

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

    I am preparing for my interview right now and this is much helpful subscribed ur channel

  • @mcq2427
    @mcq2427 3 роки тому +8

    Bro, Explain Microservises

  • @sahilkaul6199
    @sahilkaul6199 8 місяців тому

    God bless you brother

  • @ziyadbeg1821
    @ziyadbeg1821 3 роки тому

    You are great sir 😊

  • @user-uv9lf7qn3i
    @user-uv9lf7qn3i 5 місяців тому

    Amazing content , best on utube , love from Russia

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

    Well explained 👌

  • @umaparvathi606
    @umaparvathi606 3 роки тому

    Ji sooper ji really excellent after watching your classes i love coding please update webservices and spring boot microservices

  • @tannubajpai4782
    @tannubajpai4782 3 роки тому

    Nice one bro
    Thnx u for ur services

  • @a.s.raghuwanshi7028
    @a.s.raghuwanshi7028 3 роки тому

    Sir excellent 👍👍👍❤️❤️❤️ love u sir

  • @unnaipoloruvan98
    @unnaipoloruvan98 17 днів тому

    Bro you are awesome... Please create a playlist zero to advanced for spring / spring boot... I dont know where to start

  • @ruturajpowar1883
    @ruturajpowar1883 3 роки тому

    Excellent

  • @tarakantabaral4061
    @tarakantabaral4061 3 роки тому

    I like all your videos....🙏🙏🙏

  • @shubhi2648
    @shubhi2648 3 роки тому +1

    Hi sir,
    Can you also explain difference now between 'gang of 4 singleton' class and spring's '@applicationScope' class
    Thanks for awesome explanation as always. No one can do it better than you do.. !

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

    thnxxxx abi i like ur videos

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

    Thanks

  • @str6622
    @str6622 3 роки тому

    waiting for realtime uses of scopes and also please explain briefly when to use dependency injection and new keyword while creating objects in realtime.

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

    Your way of teaching is best but I like that music also which makes the learing more exciting....

  • @maan9011
    @maan9011 3 роки тому

    U super duper spring Master

  • @smishra9691
    @smishra9691 3 роки тому

    Good job

  • @neerajchavan9760
    @neerajchavan9760 3 роки тому

    Level Up! ❤️

  • @sudheerbommisetti1116
    @sudheerbommisetti1116 3 роки тому

    Waiting dude for your tutorial videos.
    Atlast......👍🙏

    • @SeleniumExpress
      @SeleniumExpress  3 роки тому +1

      On a tight schedule, Sudheer. Looking forward to post soon.

  • @gennadyshevchenko7940
    @gennadyshevchenko7940 12 днів тому

    Hi, and thanks for that video. Did you publish the video about the websockets you mentioned at 3:16:00 ?

  • @umaparvathi606
    @umaparvathi606 3 роки тому

    Thanks a lot please update spring boot tutorial and web services

  • @priyanshu4016
    @priyanshu4016 3 місяці тому

    2:14 in case of sessionscope , if i try to sent the request from curl command every time new object is creating . but from browser its working as expected

  • @RahulSharma-yc3bz
    @RahulSharma-yc3bz 3 роки тому

    very Impressive

  • @Paradise-kv7fn
    @Paradise-kv7fn 3 роки тому

    How to share applicationcontext between threads?basically i am using a distributed cache and each thread would need access to a bean created at startup…but I get an illegalstate exception…the exception makes sense because the child threads dont have the application context but how to get around this problem?
    One way that i found was to replicate that bean in my cache’s instance but was wondering if there are any better ways to do this

  • @elrachadyobi9172
    @elrachadyobi9172 3 роки тому

    Thanks youuuuuuuuuuuuuuuuuuuuuuuuuuuu a lot sir

  • @gennadyshevchenko7940
    @gennadyshevchenko7940 11 днів тому

    Can you show pom o provide link to github? I've got an error "The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'." I don't know how to fix it.

  • @khayalian
    @khayalian 3 роки тому

    Thanks for the great lecture, I'm also interested to build a custom Scope, how i can achieve it, any information could be great, Thanks.

  • @DevilT2390
    @DevilT2390 11 місяців тому

    this explanation is even better than the paid udemy courses

  • @user-ti4fq8jz8e
    @user-ti4fq8jz8e 5 місяців тому

    Hi... Could you please reply to my query?
    I have a query at 1:55:23
    The Testcontroller class is annotated with @controller annotation so it is now a singleton bean . If we use @autowired on MyBean object , then will it create only one instance of MyBean class?
    Spring creates singleton bean only once and if autowire is used on MyBean then will it create the MyBean object with Testcontroller only once and use the same MyBean object for different requests?

  • @sudheerbommisetti1116
    @sudheerbommisetti1116 3 роки тому +1

    Hi Abhilash dude,
    When we are coding back to LOVE CALCULATOR project ?
    Many students are waiting for the database(spring JDBC) connection for that project.
    Kindly give update if possible 🙏.
    & Thanks a lot for the efforts.

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

    1:24:44 we made the School class as an abstract class and making bean out of it. Is it possible because we cant instantiate the abstract class

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

    either before watching thank you

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

    What is the scope of object created by a bean. I want to use a bean of an object which uses init method once and then that bean object is shared among the whole application. My init method calls s3 and imports a file. I don't want to do that on every instance.

  • @brus5
    @brus5 3 роки тому

    Thank you Selenium Express

  • @mohdharish9834
    @mohdharish9834 3 роки тому

    Hi Abhilash can you tell me how to check api call logs in kibana I am struggling with this

  • @rohanyadav7327
    @rohanyadav7327 7 місяців тому

    Why do we need to create 2 different or more than 2 application context for spring application? Can you share any usecase of that ? 1:38:10

  • @shubhi2648
    @shubhi2648 3 роки тому +1

    How abstract class got instantiated..?(when we tried @lookup and made school class abstract)

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

    Can we create an instance for abstract component in case of prototype bean scope ?

  • @sumitpatil291
    @sumitpatil291 3 роки тому

    Hi Abhilash
    Please do post videos on spring batch.

  • @dharmasastha1150
    @dharmasastha1150 3 роки тому +2

    Hi Abhilash, It was a wonderful session !
    Assignment 01:
    While printing out two School objects, got Proxy Object as output. Unable to find the reason behind it.
    Is it because the prototype bean generated as proxy by CGLib, singleton object too created by CGLib ?

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

      around 01:26:00 q,
      I think the school class is subclassed by cglib that's why you are getting this. But the student bean injected here is a real bean and not a prototype bean. Try making the School class as final you will get error regarding subclassing not allowed. This was similar to proxyMode added in Student class, here also the proxy object was created by cglib and gave me error of i try to make it as final (complaining that sub-classing is not allowed)

  • @jayantagarwal6339
    @jayantagarwal6339 3 роки тому

    thanks! Just a query- @1:06:00 if we make the Student class as "singleton", then also, will the multiple objects be given thru the proxyMode?

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

      no it won't it will give one student object... but internally first proxy object will be created and that will get a real student object(this part remains same)

  • @vikrantharne9345
    @vikrantharne9345 3 роки тому

    at 1:23:19 u hv marked class as abstract then now that can be instantiated ?????

  • @tabishrizwan9137
    @tabishrizwan9137 3 роки тому

    Hi abhilash, by using proxymode=scopedproxymode.TARGET_CLASS student constructor also called but using @lookup student constructor didn't call during school objection creation. could you please have a look on it.

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

    This is great!!! If I make Student class as final, CGLIB giving error that Student class cannot be subclassed :D :D D

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

    Hi! Thank you for the video. One more thing about your microphone, sometimes it is to loud to hear you, sometimes is too quiet. Just want you to know it

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

    Application scope object is not created until we need it, then why @Autowired not fail? Does Spring ignore @Autowired check for property that depends on application scope component class?

  • @user-jc7ts2ou4j
    @user-jc7ts2ou4j 10 місяців тому

    Abstract classes cannot be instantiated. Then if we make the School class as Abstract, how can we create objects for the School class and it doesn't show any error here. Why?

  • @AnitaSingh-cx7sw
    @AnitaSingh-cx7sw 3 роки тому

    Level up

  • @anudeepgrandhi4988
    @anudeepgrandhi4988 3 роки тому

    Please create tutorial for microservices and spring boot

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

    wow

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

    What are some real world application of having to have multiple dispatcher servlets in one application?

  • @yoshitamahajan353
    @yoshitamahajan353 3 роки тому

    Please create for springboot and microservices also

  • @chamanjain9843
    @chamanjain9843 5 місяців тому

    Also, we can create multiple Spring singleton scope beans of the same class, just with different names, because they are stored in a ConcurrentHashMap with the name, and each time you access them by name, you will get the same object.