Annotations in Spring Boot Interview Questions and Answers | Code Decode | Part -2
HTML-код
- Опубликовано: 10 сен 2024
- In this video of code decode of Annotations in Spring boot Interview Questions and Answers we have covered some common interview questions regarding spring boot annotations
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/u...
Course Description Video :
yt.openinapp.c...
Annotations in spring boot part -1 : • Annotations in Spring ...
It’s the way to implement Dependency Injection in spring / spring boot application.
Container will provide the required bean to dependent bean at runtime
Spring provides annotation-based auto-wiring by providing @Autowired annotation.
It is used to autowire spring bean on setter methods, instance variable, and constructor.
When we use @Autowired annotation, the spring container auto-wires the bean by matching data-type.
How will container autowire the required bean in dependent bean at runtime ? It first need to create beans during startup so that it can provide beans at later stage.
How will container know who POJO / java class should be considered as bean and whom to ignore ?
@Component: It is a class-level annotation.
It is used to mark a Java class as a bean.
A Java class annotated with @Component is found during the classpath.
The Spring Framework pick it up and configure it in the application context as a Spring Bean.
It is a generic stereotype for any Spring-managed component. The specializations are @Controller, @Service, @Repository
The @Controller is a class-level annotation.
It is a specialization of @Component.
It marks a class as a web request handler. It is often used to serve web pages. It is used in conjunction with @RequestMapping annotation.
We also use @RestController when we need to send response in JSON format directly.
By default, @Controller returns a string that indicates which route to redirect. Its used mostly with JSPs. It returns URL to new JSP page where it has to be redirected
They are nothing but the specialized form of @Component annotation for certain situations. Instead of using @Component on a controller class in Spring MVC, we use @Controller, which is more readable and appropriate.
The @Controller is a class-level annotation.
It is a specialization of @Component.
It marks a class as a web request handler. It is often used to serve web pages. It is used in conjunction with @RequestMapping annotation.
We also use @RestController when we need to send response in JSON format directly.
They are nothing but the specialized form of @Component annotation for certain situations. Instead of using @Component on a controller class in Spring MVC, we use @Controller, which is more readable and appropriate.
By using @Controller annotation we do two things,
We declare that this class is a Spring bean and should be created and maintained by Spring ApplicationContext,
We indicate that its a controller in MVC setup. This latter property is used by web-specific tools and functionalities.
DispatcherServlet will look for @RequestMapping on classes that are annotated using @Controller but not with @Component.
This means @Component and @Controller are the same with respect to bean creation and dependency injection but @Controller is a specialized form of @Component. Even if you replace @Controller annotation with @Compoenent, Spring can automatically detect and register the controller class but it may not work as you expect with respect to request mapping.
It is also used at class level.
It is a specialization of @Component.
It tells the Spring that class contains the business logic.
But at the end The main task of this annotation is also to mark the class capable to become a bean in Spring container similar to component. We can use @component also and it will work the same as this annotation does.
Most Asked Core Java Interview Questions and Answers : • Core Java frequently a...
Advance Java Interview Questions and Answers : • Advance Java Interview...
Java 8 Interview Questions and Answers : • Java 8 Interview Quest...
Hibernate Interview Questions and Answers : • Hibernate Interview Qu...
Spring Boot Interview Questions and Answers : • Advance Java Interview...
Angular Playlist : • Angular Course Introdu...
SQL Playlist : • SQL Interview Question...
GIT : • GIT
Subscriber and Follow Code Decode
Subscriber Code Decode : www.youtube.co...
LinkedIn : / codedecodeyoutube
Instagram : / codedecode25
#annotations #codedecode #springbootinterviewquestions
Anybody having basic language knowledge can watch your video and gain industry level knowledge ,each and every concept is explained in detail . Can you also make detail video on apache kafka
Thanks Pranjal. Yes this video is in queue mostly tomorrow we will post something related to it👍
Please also make a third part with more annotations. Thanks for making these videos really helpful in cracking interviews.
Thanks Krishna 🙂👍
Am Fallen in Love with #CodeDecode, I am from Mech Background, working in IT field currently. When I start your playlist, You will never fail in making me understand the things in a perfect way. Thanks a Lott💌. Want more Videos.
Means a lot to us KiranKumar❤thanks for being with us🙂🙂
You are awesome.. awesome in making words simpler and understandable..thanks a lot
Thanks Reva❤️
Thank you so much. Best channel to prepare for an interview on springboot and java
Thanks Kaushik for the appreciation
Yes definitely, It is very helpful and please make 3rd part as well. :)
Sure aishwarya we will create third part as well
Thanks for making this video this is the best for beginners
You're welcome Murgesh
Great and very helpful. Thanks a lot 🙏🏾
😊👍
very informative , it clears all the doubts plz make 3rd part as well
Thanks Yatharth will create next part soon👍🙂
Thanks mam please upload more annotations
Sure Amit. We will do that👍🙂
Thanks maam, please show us more annotations
Sure Akash🙂👍
Please make the 3rd part as well. The videos are really very helpful. Thank you.
Thanks Nikita. Sure will upload soon 🙂👍
please make the second part of it as sson as possible
👍sure
nicely curated and well explained, looking for more videos.
Thanks Veera 😊👍
Hi CodeEcode, wonderful explanation. Please do add thre remaining annotations also.It will be very helpfull
sure sravanti we will upload it soon
very useful video , thank you
You're welcome
Please make the third part as well.
Sure we will create it soon
Was waiting for this vedio
🙂🙂
very understandable explanation thanks !!!! please make videos on rest of the annotations
Sure Pooja 👍🙂
Awesome 👍🏻 Explanation
Thanks Raj 🙂
Awesome. Please make more videos on spring boot annotations
Thanks Pratyush🙂👍
Very important video Thanks mam, please I would request you make video on scenario based questions on spring boot
Sure Vithal🙂👍
Thanks for this wonderful and informative video. Please make video for the left out annotations.
Sure Gaurav 👍🙂
Hi pls add third part of this .. 😊waiting
Sure we will create it soon
Informative video
Thanks🙂👍
Awesome channel
Thanks
Well explanation pls make third part too
Sure Vardhan 👍🙂
Please make third part of it.
Sure we will create it soon
Nice Questions....but honestly I need to give feedback that I feel your answers have more theory rather than explaining with simple terms (Need to cut it short). And also one more thing the audio narration levels are so sharp for theoretical explanation makes people get diverted with lot of information. Other than that you are really awesome. Great job.
Sure Aswin. we will work on reducing our content. We just tried to make it for those who don't even know about the topic that's why it might seem lame sometimes. Is that the case here Aswin ?
nice explanation
Thanks Sachin 🙂👍
But employee bean is created, even if you comment @Component on Address Bean while it is autowired, because I can see the constructor of Employee Bean is getting called... so if the constructor is being called then how can we say the Employee Bean is not created. Correct me if I am wrong.. see from timestamp 05:54
Waiting for the 3rd part. please do asap.
Sure Tejeswar 👍
Nice video
Thanks Varun 🙂👍
First on Your Video Mam
Thanks a lot Arjun 🙂🙂🙂🙂
@@CodeDecode Hey mam i have some doubts and questions regarding Junit and mockito, please mam make a series of videos on that and share your real world scenerios how code smels , how to impove our code quality , You know as i discuss you previously about this topic
Fun !
🙂🙂
Thanks 😊
🙂🙂
What will happen if we interchange service annotation and repository annotation ? will it work ?
all questions are having the annotation replacement @component then why we are studying all these annotation according to video as u demonstrate we can use always @component every where XD
For better readability we are using different annotations. You can try replacing all of them with @component and still ur app will work as is.
please make the 3rd part asap
Sure we will create it soon
Please cover @Conditional, @Profile,. @Import etc..
why did you make Address class also @Component
What is a bean. Is there a video for it
Part 1 continue , you have not completed that component scan part
Show us more annotations
Sure🙂👍
when will next one come...
we will create it soon
Hi CodeDecode, Your doing a great job by explaining the complex concepts in simpler manner.
Can you please make videos on dataStructure and algorithms.
sure kiran we will try to create videos on data structure and algorithm soon
Hello, Ma'am, I saw your many videos but you had not given any pdf of these questions if possible provide it. Because it helps us a lot if we get a pdf file.
I saw your all videos.
Yes ,if possible please provide the pdf files
Yes, you can put pdfs in discriminations.
please give the project
i want that pdf
Pdf for?
To byheart definition
Iam preparing for interview I want answers for that questiin
Ohh. Yeah every thing is in description below. 👍👍
In that pdf more content is available right, that's y iam asking