title: How to use @NotNull with spring boot?
body: <p>I have this dependency:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.hibernate.validator&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Which have it's version managed by </p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.0.4.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p>And I have this piece:</p>
  
  <pre><code>import javax.validation.constraints.NotNull;
  //other imports ommited
  
  @Component
  @ConfigurationProperties(prefix = "collector")
  public class CollectorProperties {
  
      @NotNull
      private String urlCDI;
  
      //getters and setters
  }
  </code></pre>
  
  <p>And my <code>SpringApplication.run</code> class has this pice:</p>
  
  <pre><code>@SpringBootApplication
  @EnableConfigurationProperties
  @ComponentScan({ "otherPackages", "packageWhereCollectorPropertiesIs" })
  </code></pre>
  
  <p>When I have my <code>application.properties</code> with this line</p>
  
  <pre><code>collector.urlCDI=https://www.cetip.com.br/Home
  </code></pre>
  
  <p>It works as it was supposed inside other spring beans:</p>
  
  <pre><code>//@Component class variables:
  @Autowired
  private CollectorProperties props;
  
     //inside some method
      URL url = new URL(props.getUrlCDI());
  </code></pre>
  
  <p>But when I remove it or alter property key I get lots of NPE instead of validations errors. What I'm doing wrong? Doesn't <code>hibernate-validator</code> contains an implementation of <code>javax.validation.constraints.NotNull</code> interface?</p>