title: Getting Ambiguous @ExceptionHandler method mapped for MethodArgumentNotValidException while startup of spring boot application
body: <p>I have written custom exception handler class for one of my spring controllers to validate if email attribute from request param is in the proper format. So created a new class which extends <code>ResponseEntityExceptionHandler</code> class and wrote a method with <code>@ExceptionHandler</code>.</p>
  
  <p>But during spring boot application startup, I am getting below exception which is stopping to run my project. Could someone help me to resolve this?</p>
  
  <p><strong>Exception during server startup:</strong></p>
  
  <blockquote>
    <p>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'handlerExceptionResolver' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed;<br>
    nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerExceptionResolver]: Factory method 'handlerExceptionResolver' threw exception;<br>
    nested exception is java.lang.IllegalStateException: Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]: {public com.TestVO com.handler.exception.TestExceptionHandler.methodArgumentNotValidException(org.springframework.web.bind.MethodArgumentNotValidException), public final org.springframework.http.ResponseEntity org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler.handleException(java.lang.Exception,org.springframework.web.context.request.WebRequest) throws java.lang.Exception}</p>
  </blockquote>
  
  <p>Custom Class to handle <code>MethodArgumentNotValidException</code>:</p>
  
  <pre><code>@ControllerAdvice
  public class ExceptionHandler extends ResponseEntityExceptionHandler {
  
      @ExceptionHandler(MethodArgumentNotValidException.class)
      @ResponseStatus(HttpStatus.BAD_REQUEST)
      @ResponseBody
      public ErrorVO processValidationError(MethodArgumentNotValidException ex) {
          BindingResult result = ex.getBindingResult();
          List&lt;FieldError&gt; fieldErrors = result.getFieldErrors();
          FieldError fieldError = fieldErrors.get(0);
          ErrorVO dto = new ErrorVO(fieldError.getDefaultMessage());
          return dto;
      }
  }
  </code></pre>