What does the @ExceptionHandler annotation do in a Spring Boot application?

  • Handles exceptions at the controller level.
  • Defines a new exception class.
  • Handles exceptions at the global level.
  • Specifies a custom HTTP status code.
The @ExceptionHandler annotation in Spring Boot is used to handle exceptions at the global level. It allows you to define methods that can handle specific exceptions across multiple controllers. When an exception of the specified type occurs, the corresponding method is invoked to handle it. This is an essential part of effective exception handling in Spring Boot. The other options describe different functionalities or are incorrect.
Add your answer
Loading...

Leave a comment

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