title: Access application properties within SpEL in Spring xml configuration
body: <p>I'm trying to configure a spring bean based on an application property, my end goal is described in the following pseudo code:</p>
  
  <pre><code>if ${my.config}
      &lt;bean id="myBean" class="path.to.MyBeanImplOne" /&gt;
  else
      &lt;bean id="myBean" class="path.to.MyBeanImplTwo" /&gt;
  end
  </code></pre>
  
  <p>where <code>my.config</code> is a boolean property.
  According to <a href="http://www.baeldung.com/spring-expression-language" rel="nofollow noreferrer">this</a> SpEL guide, <code>#{${my.config} ? 'path.to.MyBeanImplOne' : 'path.to.MyBeanImplTwo'}</code> is a valid expression, so I tried the following configuration:</p>
  
  <pre><code>&lt;bean id="myBean" class="#{${my.config} ? 'path.to.MyBeanImplOne' : 'path.to.MyBeanImplTwo'}" /&gt;
  </code></pre>
  
  <p>but got the following exception:</p>
  
  <pre><code>Expression parsing failed; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E: After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
  </code></pre>
  
  <p>I can't find documentation for accessing properties in SpEL expressions for xml configuration. Is this supported only in Java configuration?</p>
  
  <p>I've seen a number of proposed solutions to my problem (some of which are in this <a href="https://stackoverflow.com/questions/23872644/conditional-spring-configuration">question</a>). I'd like to not use <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html#expressions-beandef-xml-based" rel="nofollow noreferrer">systemProperties</a> since I feel this sort of configuration should not be specified a run arguments, and I feel the use of <a href="http://spring.io/blog/2011/02/11/spring-framework-3-1-m1-released#enter-bean-definition-profiles" rel="nofollow noreferrer">profiles</a> is overkill for this particular use case.</p>
  
  <p>Has someone been able to do what I've attempted successfully? Or can someone confirm whether or not the syntax I've tried to use is indeed not supported in xml configuration.</p>