In Spring Boot, annotations play a crucial role in defining behavior, configurations, and bean management.
1. @SpringBootApplication
- Combines three annotations: `@Configuration`, `@EnableAutoConfiguration`, and `@ComponentScan`.
- Marks the main class that bootstraps the Spring application.
2. @RestController
- Combines `@Controller` and `@ResponseBody`.
- Used for creating RESTful web services. It automatically serializes return objects to JSON or XML.
3. @RequestMapping
- Maps HTTP requests to handler methods of MVC and REST controllers.
- Can be applied at both class and method levels.
0 Comments