@RestControllerAdvice
Learn @RestControllerAdvice (Exception Handling, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Fresher Notes @RestControllerAdvice is a global advice class whose handler methods write their return value straight to the response body (it equals @ControllerAdvice + @ResponseBody ). Use : build JSON error responses for REST APIs in one place. Return types : a plain object, a ResponseEntity , or ProblemDetail are all serialized by message converters.