title: Spring Boot: using SpEL collection selection from YAML in @ConditionalOnExpression
body: <p>I have a Spring Boot application with a YAML configuration that contains a feature list like this:</p>
  <pre><code>features:
    - key: feature1
      enabled: true
      description: First feature
    - key: feature2
      enabled: false
      description: Second feature
  ...
  </code></pre>
  <p>I would like to use @ConditionalOnExpression to conditionally initialize beans related to those features, identifying them by keys. Since &quot;features&quot; property is a list, it seems I need collection selection to do this. I have tried these two options for the annotation's value:</p>
  <pre><code>@ConditionalOnExpression(&quot;${features.?[key == 'feature1'][0].enabled}&quot;)
  
  @ConditionalOnExpression(&quot;${features}.?[key == 'feature1'][0].enabled&quot;)
  </code></pre>
  <p>But both give the same error on startup:</p>
  <pre><code>org.springframework.expression.spel.SpelParseException: EL1041E: After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
  </code></pre>
  <p>If I pass the expression (without ${}) to SpelExpressionParser.parseExpression() and then evaluate it (against a list of feature objects built programmatically), it works as expected and returns the value of &quot;enabled&quot; property. So the expression's structure seems to be OK, and the problem is how I use it in @ConditionalOnExpression. What exactly can I be doing wrong?</p>