Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-11072

In location attribute of <context:property-placeholder /> SpEL expressions are not evaulated

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.2.4
    • Fix Version/s: None
    • Component/s: Core, Core:SpEL
    • Labels:
    • Last commented by a User:
      true

      Description

      Given you include an SpEL expression in the location attribute of <context:property-placeholder />, when the context is loaded, then you will get an exception implying the SpEL expression was not evaluated but taken literally. E.g.:

      <context:property-placeholder local-override="true" system-properties-mode="OVERRIDE" location="classpath*:config.properties,config-#{environment['config.environment'] ? environment['config.environment'] : 'embvedded'}.properties,config-overrides.properties">

      Exception in thread "main" org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [config-#{environment['config.environment'] ? environment['config.environment'] : 'config'}.properties] cannot be opened because it does not exist
      	at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:87)
      ...

      See for workaround: http://stackoverflow.com/questions/6900259/using-contextproperty-placeholder-location-with-spring-el

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            sibidiba sibidiba
            Last updater:
            Juergen Hoeller
          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Days since last comment:
              4 years, 3 weeks, 2 days ago