title: How to import value from properties file and use it in annotation?
body: <p>I have a class that is an entity:</p>
  
  <p>Class.java</p>
  
  <pre><code>@Entity
  public class Class {
      @Id
      @GeneratedValue
      private Long id;
  
      @NotNull
      @Range(min = 0, max = 10)
      private double value;
  }
  </code></pre>
  
  <p>I want to get rid of the hard-coded values from the <code>@Range</code> annotation and load them from a configuration file. </p>
  
  <p>constraints.properties</p>
  
  <pre><code>minVal=0
  maxVal=10
  </code></pre>
  
  <p>This is what I've tried:</p>
  
  <pre><code>@Component
  @Entity
  @PropertySource("classpath:/constraints.properties")
  public class Class {
  
      @Value("${minVal}")
      private final long minValue;
      @Value("${maxVal}")
      private final long maxValue;
  
      @Id
      @GeneratedValue
      private Long id;
  
      @NotNull
      @Range(min = minValue, max = maxValue)
      private double value;
  }
  </code></pre>
  
  <p>The error I get is <code>attribute value must be constant</code>. How the initialization of these fields should be performed to get the result I want?</p>