한울이

[SPRING] @RestControllerAdvice can not handle HttpRequestMethodNotSupportedException 본문

PROGRAMMING

[SPRING] @RestControllerAdvice can not handle HttpRequestMethodNotSupportedException

gksdnf050 2022. 8. 21. 20:01

회사에서 업무를 하다가 HttpRequestMethodNotSupportedException 에 대한 처리를 해야 하는 상황이 생겨서RestControllerAdvice를 사용하여 exception을 handling 하고 있는 곳에 추가해서 처리하려고 했다.

 

예시

그런데 내가 정의한 ExceptionHandler 에서 exception이 처리되지않고DefaultHandlerExceptionResolver에서 exception이 처리되었다.

알고 보니 basePackageClasses = BaseController.class 부분이 문제였다.

참조

https://stackoverflow.com/questions/56459170/spring-controlleradvice-fail-to-override-handlehttprequestmethodnotsupported/56642501

 

Spring ControllerAdvice - Fail to override handleHttpRequestMethodNotSupported() in ResponseEntityExceptionHandler

Here's a few facts for the situation that I'm currently facing I have recently built a RestControllerAdvice with variousExceptionHandler as a global exception handler for my Spring RestController....

stackoverflow.com

 

Comments