title: javax validation constraints not working in Spring Boot
body: <p>I cannot get annotations such as @NotEmpty, @NotBlank and @NotNull to fire in my Spring Boot application.</p>
  
  <p>I've followed this (maven) example:</p>
  
  <p><a href="https://spring.io/guides/gs/validating-form-input/" rel="noreferrer">https://spring.io/guides/gs/validating-form-input/</a></p>
  
  <p>...and I don't see what I am doing wrong.</p>
  
  <p>POJO:</p>
  
  <pre><code>import javax.validation.constraints.NotBlank;
  
  @Data
  @AllArgsConstructor
  @NoArgsConstructor
  public class College
  {    
      @NotBlank
      private String collegeCode;
  .
  .
  .
  </code></pre>
  
  <p>Spring controller:</p>
  
  <pre><code>@RequestMapping(value="/addCollege", method = RequestMethod.POST) 
  public String addCollege(@Valid @ModelAttribute("college") College college, BindingResult bindingResult, Model model, HttpSession session)
  {
      if(bindingResult.hasErrors()) //this is never true
      {
          logger.debug("Errors when adding new college!!!");
          return "admin/colleges/addCollege";
      }
      collegeProcessor.saveCollege(college);
      return getAllColleges(model, session);
  }
  </code></pre>
  
  <p>Screen:</p>
  
  <pre><code>&lt;form action="#" th:action="${addOrEdit} == 'add' ? @{/addCollege} : @{/updateCollege}" th:object="${college}" method="post"&gt;
  
      &lt;table class="table"&gt;
  
          &lt;tr&gt;
              &lt;td&gt;College Code&lt;/td&gt;
              &lt;td&gt;&lt;input size="10" name="collegeCode" th:field="*{collegeCode}"/&gt;&lt;/td&gt;
              &lt;div id="errors" th:if="${#fields.hasErrors('collegeCode')}" th:errors="*{collegeCode}"&gt;&lt;/div&gt;
          &lt;/tr&gt;
  .
  .
  .
  
  </code></pre>
  
  <p>As well as @NotBlank, I have tried @NotEmpty and @NotNull, but the same thing happens.  My screen does not validate the input, and allows a college object with an empty collegeCode to be saved.</p>
  
  <p>The interesting thing is if I change my POJO to use the deprecated Hibernate validator instead... </p>
  
  <pre><code>import org.hibernate.validator.constraints.NotBlank;
  
  @Data
  @AllArgsConstructor
  @NoArgsConstructor
  public class College
  {
      @NotBlank
      private String collegeCode;
  .
  .
  .
  </code></pre>
  
  <p>...then the validation DOES fire, and the screen prevents me from saving a College object with an empty collegeCode.</p>
  
  <p>Can anyone tell me why my validation doesn't work when using the javax.validation.constraints validators?</p>