title: Spring Boot SpEL and configuration property binding to constant expressions
body: <p><strong>Using Sprint Boot 2.0.4.RELEASE</strong>, I have the following properties class (simplified):</p>
  
  <pre><code>@Configuration
  @EnableConfigurationProperties(MyOtherHierarchicalNonConstantProperties.class)
  public class AppConfiguration {
      public static final String MY_CONSTANT = "${path.to.my-constant}";
  }
  </code></pre>
  
  <p>and the <code>application.yml</code> (also simplified):</p>
  
  <pre><code>path.to.my-constant: mystring
  </code></pre>
  
  <h3>The Problem</h3>
  
  <p>The value from <code>application.yml</code> never gets assigned to <code>MY_CONSTANT</code>, which is required for use as an argument to annotations. (I want all configurable options between build environments to be set in <code>application.yml</code>!) The value of <code>MY_CONSTANT</code> ends up being <code>${path.to.my-constant}</code>.</p>
  
  <p>I have been working with this issue for pretty much the entire day, also tried several different options after lots of searching, such as:</p>
  
  <ul>
  <li><code>${${path.to.my-constant}}</code> #1</li>
  <li><code>#{${path.to.my-constant}}</code> #2</li>
  <li><code>${#{path.to.my-constant}}</code></li>
  <li><code>#{'${path.to.my-constant}'}</code></li>
  <li>and many many more...</li>
  </ul>
  
  <h3>Additional (Maybe Helpful) Information</h3>
  
  <p>In some cases I get the exact expression as the value of the string (as said above), but in some cases I get exceptions such as: </p>
  
  <ul>
  <li>#1: <code>IllegalArgumentException</code> from <code>PropertyPlaceholderHelper.parseStringValue</code> saying <code>Could not resolve placeholder 'mystring' in value "${${path.to.my-constant}}"</code></li>
  <li>#2: <code>SpelEvaluationException</code> from <code>PropertyOrFieldReference.readProperty</code> saying <code>EL1008E: Property or field 'mystring' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public or not valid?</code></li>
  </ul>
  
  <p>Both indicating that if the initial expression is further wrapped inside other SpEL braces, the inner expression gets translated to the desired value. But after that, it refuses to be extracted from the outer braces. (For quite a long time, I was trying hundreds of SpEL operations to try and somehow "extract" the value from the outer braces...)</p>
  
  <p>One thing I had also tried, is moving the constant into the other properties class with the <code>@ConfigurationProperties</code> annotation hoping it would change something, but the results seem to be identical.</p>
  
  <h3>The Plea</h3>
  
  <p>I know the question about assigning configuration properties to constants in Spring Boot has been asked a lot, I have also tried <em>every option</em> on planet Earth after coming here to ask this and am hopelessly lost.</p>
  
  <p><strong>Someone please, for once and for all, put and end to this miserable lack of single source of truth about configurable constant expressions and tell us how to do this the right way!</strong> (And if Spring Boot never intended for it to be possible, that information could also be helpful to know...)</p>
  
  <p>PS! No nasty hacks please...</p>