title: Why a validation message is not replaced in Spring Boot?
body: <p>Now I developed REST API using Spring Boot.</p>
  
  <p>I try to validate path parameter and handle a exception with custom message like this.</p>
  
  <p><em>FooController.java</em></p>
  
  <pre><code>@Validated
  @RestController
  @RequiredArgsConstructor
  public class FooController {
  
    private final BarService service;
  
    @GetMapping(value = "/test/{id}")
    public void invoke(@PathVariable @Digits(integer = 10, fraction = 0, message = "{message}") Long id) {
      service.get(id);
      ...
    }
  }
  </code></pre>
  
  <p><em>ApiExceptionHandler.java</em></p>
  
  <pre><code>@RestControllerAdvice
  @RequiredArgsConstructor
  public class ApiExceptionHandler {
  
    @ExceptionHandler(ConstraintViolationException.class)
    public ResponseEntity&lt;Object&gt; handleConstraintViolationException(ConstraintViolationException exception) {
      Map&lt;String, String&gt; messages = new HashMap&lt;&gt;();
      for (ConstraintViolation violation : exception.getConstraintViolations()) {
        messages.put("message", violation.getMessage());
      }
      return new ResponseEntity&lt;&gt;(messages, HttpStatus.BAD_REQUEST);
    }
  }
  </code></pre>
  
  <p><em>ValidationMessages.properties</em></p>
  
  <pre><code>message={0} must not be more than {integer} digits
  </code></pre>
  
  <p>When I call this API by more than 10 digits (For example, [<code>GET /test/12345678901</code>]) to happen 400 error.</p>
  
  <p>My expected response is</p>
  
  <pre><code>{
    message : id must not be more than 10 digits
  }
  </code></pre>
  
  <p>But, actual response is</p>
  
  <pre><code>{
    message : {0} must not be more than 10 digits
  }
  </code></pre>
  
  <p>So, my question is "Why a validation message is not replaced".</p>
  
  <p>If this approach is wrong then is there any approach to come get expected response?</p>
  
  <p>Thank you for reading my question.</p>
  
  <p><strong><em>Appendix</em></strong>
  Used Spring Boot version is 2.1.1</p>