In Spring Boot, which annotation is used to handle exceptions at the controller level?
- @ExceptionHandler
- @ControllerAdvice
- @RestController
- @RequestMapping
In Spring Boot, the @ExceptionHandler annotation is used to handle exceptions at the controller level. This annotation allows you to define methods within a controller that can handle specific exceptions thrown by that controller. The other options, such as @ControllerAdvice, @RestController, and @RequestMapping, have different roles and are not used for handling exceptions directly at the controller level.
Loading...
Related Quiz
- What is the purpose of using Ribbon in a microservices architecture in Spring Cloud?
- How can you handle cache eviction in a distributed caching environment in Spring Boot?
- The @RequestBody annotation is used to bind the value of the HTTP request body to a(n) _____ in a controller method.
- In Spring Boot, the _____ annotation is used to conditionally enable a configuration based on the presence of a specific property.
- Imagine you are developing a Spring Boot application with multiple data sources. How would you configure and use these data sources?