title: How to resolve this Error for custom api error message .If i remove both method of this class then project run without error
body: <p>I'm getting this error message:</p>
  <blockquote>
  <p>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; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerExceptionResolver]: Factory method 'handlerExceptionResolver' threw exception; nested exception is java.lang.IllegalStateException: Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]: {public org.springframework.http.ResponseEntity com.Internity.extraservice.CustomRestExceptionHandler.handleMethodArgumentNotValid(org.springframework.web.bind.MethodArgumentNotValidException,org.springframework.http.HttpHeaders,org.springframework.http.HttpStatus,org.springframework.web.context.request.WebRequest), 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>I'm using this code:</p>
  <pre><code>@ControllerAdvice
  @RestControllerAdvice
  public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler{
  
  
     @ExceptionHandler(MethodArgumentNotValidException.class)
     protected ResponseEntity&lt;Object&gt; handleMethodArgumentNotValid(
       MethodArgumentNotValidException ex, 
       HttpHeaders headers, 
       HttpStatus status, 
       WebRequest request) {
         List&lt;String&gt; errors = new ArrayList&lt;String&gt;();
         for (FieldError error : ex.getBindingResult().getFieldErrors()) {
             errors.add(error.getField() + &quot;: &quot; + error.getDefaultMessage());
         }
         for (ObjectError error : ex.getBindingResult().getGlobalErrors()) {
             errors.add(error.getObjectName() + &quot;: &quot; + error.getDefaultMessage());
         }
      
         CustomApiError customApiError = 
           new CustomApiError(new Date(),HttpStatus.BAD_REQUEST, ex.getLocalizedMessage(), errors);
         return handleExceptionInternal(
           ex, customApiError, headers, customApiError.getStatus(), request);
      
     
   
     }
  
  
  /*@ExceptionHandler({ Exception.class })
  public ResponseEntity&lt;Object&gt; handleAll(Exception ex, WebRequest request) {
      CustomApiError customApiError = new CustomApiError(new Date(),HttpStatus.INTERNAL_SERVER_ERROR, ex.getLocalizedMessage(), &quot;error occurred&quot;);
      return new ResponseEntity&lt;Object&gt;(
              customApiError, new HttpHeaders(), customApiError.getStatus());
  }*/
  }
  </code></pre>