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.
Loading...
Related Quiz
- When designing RESTful APIs in Spring Boot, the _____ annotation can be used to handle HTTP GET requests specifically.
- How can you ensure that the ApplicationContext is not loaded while performing unit testing on web layers in Spring Boot?
- Which tool is commonly used for monitoring the performance of a Spring Boot application?
- In what scenario would you use the @Modifying annotation in a Spring Data JPA repository method?
- When defining a global exception handler in Spring Boot, you can use the _____ argument to access the details of the occurred exception.