title: How do I customize default error message from spring @Valid validation?
body: <p>DTO:</p>
  
  <pre><code>public class User {
  
      @NotNull
      private String name;
  
      @NotNull
      private String password;
  
      //..
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@RequestMapping(value = "/user", method = RequestMethod.POST)
  public ResponseEntity&lt;String&gt; saveUser(@Valid @RequestBody User user) {
      //..
      return new ResponseEntity&lt;&gt;(HttpStatus.OK);
  }
  </code></pre>
  
  <p>Default json error:</p>
  
  <pre><code>{"timestamp":1417379464584,"status":400,"error":"Bad Request","exception":"org.springframework.web.bind.MethodArgumentNotValidException","message":"Validation failed for argument at index 0 in method: public org.springframework.http.ResponseEntity&lt;demo.User&gt; demo.UserController.saveUser(demo.User), with 2 error(s): [Field error in object 'user' on field 'name': rejected value [null]; codes [NotNull.user.name,NotNull.name,NotNull.java.lang.String,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.name,name]; arguments []; default message [name]]; default message [may not be null]],"path":"/user"}
  </code></pre>
  
  <p>I would like to have my custom json for each error occured. How do I accomplish that?</p>