filmov
tv
Annotations in Spring boot with Explanation| Spring boot Interview Questions and Answers Code Decode
Показать описание
In this video of code decode we have explained about Annotations in Spring boot. Annotations in spring boot is very important Interview in Spring boot interview questions and answers.
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
Course Description Video :
Spring boot annotations
Spring Boot is the most popular Java framework. Spring Boot built upon spring framework. It minimize the amount of configuration and boilerplate code you need to get started.
The Java provided support for Annotations from Java 5.0.
Prior to that, the behavior of the Spring Framework was largely controlled through XML configuration. Today, the use of annotations provide us tremendous capabilities in how we configure the Spring Framework.
Spring Annotations are a form of metadata. Annotations are used to provide supplemental information about a program. It does not have a direct effect on the operation of the code they annotate. It does not change the action of the compiled program.
@SpringBootApplication
It is a combination of three annotations
@EnableAutoConfiguration,
@ComponentScan, and
@Configuration.
if you see at their parent packages:
So we can say this Spring boot annotations can’t exist on its own. It needs spring framework annotations to work.
@Target tag is used to specify at which type, the annotation is used.
Element Types Where the annotation can be applied
TYPE class, interface or enumeration
FIELD fields
METHOD methods
CONSTRUCTOR constructors
LOCAL_VARIABLE local variables
ANNOTATION_TYPE annotation type
PARAMETER parameter
@Retention annotation is used to specify to what level annotation will be available.
RetentionPolicy.SOURCE - refers to the source code, discarded during compilation. It will not be available in the compiled class.
RetentionPolicy.CLASS refers to the .class file, available to java compiler but not to JVM . It is included in the class file.
RetentionPolicy.RUNTIME refers to the runtime, available to java compiler and JVM .
By default, annotations are not inherited to subclasses. The @Inherited annotation marks the annotation to be inherited to subclasses.
The @Documented Marks the annotation for inclusion in the documentation.
@Configuration
Tags the class as a source of bean definitions for the application context.
Point to note-
The main application class is also a bean, as it's annotated with @Configuration, which is a @Component.
@EnableAutoConfiguration
For example, when we define the spring-boot-starter-web dependency in our classpath, Spring boot auto-configures Tomcat and Spring MVC.
Subscriber and Follow Code Decode
#codedecode #Springbootannotations #springbootinterviewquestionsandanswers
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
Course Description Video :
Spring boot annotations
Spring Boot is the most popular Java framework. Spring Boot built upon spring framework. It minimize the amount of configuration and boilerplate code you need to get started.
The Java provided support for Annotations from Java 5.0.
Prior to that, the behavior of the Spring Framework was largely controlled through XML configuration. Today, the use of annotations provide us tremendous capabilities in how we configure the Spring Framework.
Spring Annotations are a form of metadata. Annotations are used to provide supplemental information about a program. It does not have a direct effect on the operation of the code they annotate. It does not change the action of the compiled program.
@SpringBootApplication
It is a combination of three annotations
@EnableAutoConfiguration,
@ComponentScan, and
@Configuration.
if you see at their parent packages:
So we can say this Spring boot annotations can’t exist on its own. It needs spring framework annotations to work.
@Target tag is used to specify at which type, the annotation is used.
Element Types Where the annotation can be applied
TYPE class, interface or enumeration
FIELD fields
METHOD methods
CONSTRUCTOR constructors
LOCAL_VARIABLE local variables
ANNOTATION_TYPE annotation type
PARAMETER parameter
@Retention annotation is used to specify to what level annotation will be available.
RetentionPolicy.SOURCE - refers to the source code, discarded during compilation. It will not be available in the compiled class.
RetentionPolicy.CLASS refers to the .class file, available to java compiler but not to JVM . It is included in the class file.
RetentionPolicy.RUNTIME refers to the runtime, available to java compiler and JVM .
By default, annotations are not inherited to subclasses. The @Inherited annotation marks the annotation to be inherited to subclasses.
The @Documented Marks the annotation for inclusion in the documentation.
@Configuration
Tags the class as a source of bean definitions for the application context.
Point to note-
The main application class is also a bean, as it's annotated with @Configuration, which is a @Component.
@EnableAutoConfiguration
For example, when we define the spring-boot-starter-web dependency in our classpath, Spring boot auto-configures Tomcat and Spring MVC.
Subscriber and Follow Code Decode
#codedecode #Springbootannotations #springbootinterviewquestionsandanswers
Комментарии