79836696

Date: 2025-12-03 08:55:11
Score: 1
Natty:
Report link

In the Spring docs it is written

https://docs.spring.io/spring-framework/reference/web/webflux/controller/ann-advice.html

that @ControllerAdvice annotation can be made more specific by annotation attributes. In my case, the rest controllers in the system are annotated with @RestController so I can narrow down the scope of my controller advice to them with this:

@ControllerAdvice(annotations = RestController.class)
@Order(Ordered.HIGHEST_PRECEDENCE)
public class RestExceptionHandler extends ResponseEntityExceptionHandler {
...
}
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @ControllerAdvice
  • User mentioned (0): @RestController
  • Self-answer (0.5):
Posted by: riskop