In a Spring Boot application, the _____ annotation can be used to define a class that will handle exceptions for all controllers.

  • @ExceptionHandler
  • @ControllerAdvice
  • @GlobalExceptionHandler
  • @ExceptionController
In Spring Boot, the @ControllerAdvice annotation can be used to define a class that handles exceptions globally for all controllers. This is a common practice to centralize exception handling logic. The other options are not used for this specific purpose. @ExceptionHandler is used at the method level, @GlobalExceptionHandler and @ExceptionController are not standard annotations in Spring Boot.
Add your answer
Loading...

Leave a comment

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