title: Spring Boot validation message is not being resolved
body: <p>I am having trouble getting my validation message to be resolved.</p>
  
  <p>I have been searching and reading through the web and SO for some hours now, I want to relate the question with the marked answer of <a href="https://stackoverflow.com/questions/4805168/customize-spring-validation-error">Customize spring validation error</a></p>
  
  <p>I do have a <code>MessageSource</code> bean defined and the <em>messages.properties</em> it getting read correctly, as I also use it for regular text to be displayed with <code>th:text="#{some.prop.name}</code>, which does work absolutely fine.
  It is just the validation error that won't work the way it should.
  I'm sure it's a stupid mistake I just overlook...
  The validation itself works fine.</p>
  
  <p>Constraint:</p>
  
  <pre><code>@NotEmpty(message="{validation.mail.notEmpty}")
  @Email()
  private String mail;
  </code></pre>
  
  <p>messages.properties:</p>
  
  <pre><code># Validation
  validation.mail.notEmpty=The mail must not be empty!
  </code></pre>
  
  <p>Template part:</p>
  
  <pre><code>&lt;span th:if="${#fields.hasErrors('mail')}" th:errors="*{mail}"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>The displayed text:</p>
  
  <pre><code>{validation.mail.notEmpty}
  </code></pre>
  
  <p>I tried a lot of variation, all without success.</p>
  
  <pre><code>@NotEmpty(message="validation.mail.notEmpty")
  @NotEmpty(message="#{validation.mail.notEmpty}")
  </code></pre>
  
  <p>Will just show the exact value of the messages string, no parsing.</p>
  
  <pre><code>&lt;span th:if="${#fields.hasErrors('mail')}" th:errors="${mail}"&gt;&lt;/span&gt;
  &lt;span th:if="${#fields.hasErrors('mail')}" th:errors="#{mail}"&gt;&lt;/span&gt;
  &lt;span th:if="${#fields.hasErrors('mail')}" th:errors="#{*{mail}}"&gt;&lt;/span&gt;
  &lt;span th:if="${#fields.hasErrors('mail')}" th:errors="#{__*{mail}__}"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>Will result in an error.</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>After debugging, I stumbled up on this:</p>
  
  <p>Class: <code>org.springframework.context.support.MessageSourceSupport</code></p>
  
  <p>Method: <code>formatMessage(String msg, Object[] args, Locale locale)</code></p>
  
  <p>will be called with</p>
  
  <p><code>formatMessage("{validation.mail.notEmpty}", null, locale /*German Locale*/)</code></p>
  
  <p>And it will run into <code>if (messageFormat == INVALID_MESSAGE_FORMAT) {</code></p>
  
  <p>So... my message format is not correct. This is way out of my scope/knowledge. Anyone knows what that means?</p>