title: Spring boot rest API @Valid @ExceptionHandler only working inside RestController
body: <p>I would like to validate the entity at controller level for Spring rest api.
  Here is my code:</p>
  
  <pre><code>@RestController
  @RequestMapping("/orgs")
  public class OrganizationController {
      @PostMapping("/")
      public ResponseEntity&lt;ValidationResponse&gt; addOrganization(@Valid @RequestBody Organization organization){
          //code here
      }
  
      @ExceptionHandler(MethodArgumentNotValidException.class)
      public ResponseEntity&lt;ValidationResponse&gt; invalidInput(MethodArgumentNotValidException ex) {        
          ValidationResponse response = new ValidationResponse();
          response.setSuccess(false);
          response.setMessage(ex.getMessage());
  
          return new ResponseEntity&lt;ValidationResponse&gt;(response, HttpStatus.BAD_REQUEST);
      }
  
  }
  </code></pre>
  
  <p>If I include ExceptionHandler within my controller class it is working fine. But if I move this exceptionHandler inside the @ControllerAdvice like below its NOT working.</p>
  
  <pre><code>@ControllerAdvice
  public class ExceptionHandlingController {
  
      @ExceptionHandler(MethodArgumentNotValidException.class)
      public ResponseEntity&lt;ValidationResponse&gt; invalidInput(MethodArgumentNotValidException ex) {
          ValidationResponse response = new ValidationResponse();
          response.setSuccess(false);
          response.setMessage(ex.getMessage());
          return new ResponseEntity&lt;ValidationResponse&gt;(response, HttpStatus.BAD_REQUEST);
      }
  }
  </code></pre>
  
  <p>From the console logs I found that it was scanned:</p>
  
  <pre><code>ExceptionHandlerExceptionResolver - Detected @ExceptionHandler methods in defaultExceptionHandler
  ExceptionHandlerExceptionResolver - Detected @ExceptionHandler methods in exceptionHandlingController
  </code></pre>
  
  <p>But ExceptionHandler methods is NOT getting called.</p>
  
  <p>Am I did anything wrong ?</p>