Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]

Springs ResponseEntityExceptionHandler has a method handleException which is annotated with :

@ExceptionHandler({     
        ...
        MethodArgumentNotValidException.class,
        ... 
    })

Your method handleMethodArgumentNotValidException is also annotated to handle MethodArgumentNotValidException. So spring finds two methods that should be used to handle the same exception, that is the reason for the exception.

**Solution **
Do not add a new method handleMethodArgumentNotValidException instead just override the method ResponseEntityExceptionHandler.handleMethodArgumentNotValid , and do not annotate it.
Your class ErrorWrapper must extend ResponseEntity for that.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)