What is the role of the @ControllerAdvice annotation in a Spring Boot application?
- To define request mapping for a controller.
- To handle exceptions at the controller level.
- To specify the HTTP request method.
- To declare a controller class.
The @ControllerAdvice annotation in a Spring Boot application is used to handle exceptions at the controller level. It allows you to define global exception handling logic that can be applied across multiple controllers. This is particularly useful for defining consistent error handling behavior in your application. The other options do not accurately describe the role of @ControllerAdvice.
Loading...
Related Quiz
- How can you configure different token lifetimes for different OAuth2 clients in a Spring Boot application?
- In Spring Boot, the _____ annotation is used to indicate that a method's return value should be stored in the cache.
- What is the main purpose of Auto Configuration in Spring Boot?
- How would you design a Spring Cloud application to handle failovers and service unavailability, ensuring minimal impact on the user experience?
- In Spring Boot, how do you configure the TestRestTemplate to work with a specific profile during integration testing?