title: @InitBinder in spring boot not working with @RequestBody
body: <p>If I use @InitBinder without limiting it,it is working fine with @RequestBody to validate my objects.</p>
  
  <pre><code>@InitBinder
  private void initBinder(WebDataBinder binder) {
      binder.setValidator(validator);
  }
  
  
  
  @RequestMapping(method=RequestMethod.POST)
  public CustomerQuickRegisterEntity saveNewCustomer(@Valid @RequestBody  CustomerQuickRegisterEntity customerEntity,BindingResult result)
  {
      if(result.hasErrors())
      {
          return new CustomerQuickRegisterEntity();
      }
      return customerQuickRegisterRepository.save(customerEntity);
  
  }
  </code></pre>
  
  <p>But problem is that when i limit it to just one object by doing it as <code>@InitBinder("customerEntity")</code> it is not validating the object. So I have searched through stackoverflow and found that <code>@InitBinding</code> only works with objects annotated with <code>@ModelAttribute</code>. Then my question is that it is working fine with <code>@RequestBody</code> when I use it as <code>@InitBinder</code> but does not work well when I use it as <code>@InitBinder("customerEntity")</code> ...why is it so?
  Is there any other way to validate Objects(Not properties of object Individually) associated with <code>@RequestBody</code></p>