Spring Boot Annotations to Prepare For Interviews

Spring Boot comes with a large number of annotations that are used to configure and customize the behavior of various components. Here is a comprehensive list of annotations in Spring Boot:

@SpringBootApplication: This annotation is used to mark the main class of a Spring Boot application. It combines the functionality of @Configuration@EnableAutoConfiguration, and @ComponentScan annotations.

@Configuration: It tells Spring that the class contains bean definitions and configuration logic. By annotating a class with @Configuration, Spring treats it as a source of bean definitions, and the methods within the class annotated with @Bean are used to define beans

@ComponentScan: This annotation is used to specify the packages that should be scanned for Spring components such as controllers, services, and repositories.

@EnableAutoConfiguration: This annotation is used to enable automatic configuration of the Spring Boot application based on the classpath and the properties in the application.properties or application.yml file.

@RestController: This annotation is used to mark a class as a controller that handles incoming HTTP requests and returns the response in the form of JSON, XML, or other formats.

@Controller: This annotation is used to mark a class as a controller that handles incoming HTTP requests and returns the response in the form of a view.

@Service: This annotation is used to mark a class as a service that provides business logic to the application.

@Repository: This annotation is used to mark a class as a repository that provides data access to the application.

Click Here