Which of the following annotations is used to handle exceptions globally across the whole application in Spring Boot?

  • @ControllerAdvice
  • @ExceptionHandler
  • @ResponseBodyAdvice
  • @GlobalExceptionHandler
The correct annotation to handle exceptions globally across the entire Spring Boot application is @ControllerAdvice. This annotation allows you to define global exception handlers that can be applied to multiple controllers. It's a powerful tool for managing exceptions consistently throughout your application. The other options are not used for this purpose.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *