Announcement Announcement Module
Collapse
No announcement yet.
Expressions in an import tag Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Expressions in an import tag

    I have been working on an application that loads spring security beans from a separate xml file based upon the settings in a properties file. However, it looks like spring expressions fail to work in the import tag, which surprised me. Here is a summarized look at my configuration:

    Code:
    <util:properties id="appProperties" location="classpath:/#{systemProperties['environment'] ?: 'dev'}.properties" />
    
    <import resource="#{ appProperties['security.context'] }"/>
    The idea is to build using either dev.properties or prod.properties, and automatically import security beans customized to those environments. Unfortunately, when I try this I get the following:
    Caused by: org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 1 in XML document from URL [file:/target/test-classes/#{ appProperties['security.context'] }] is invalid; nested exception is org.xml.sax.SAXParseException: Content is not allowed in prolog.
    It looks to me like the expression isn't being evaluated. If I manually replace #{} with the value in the properties file, it works perfectly.

    Did I do something wrong, or is this a bug? If not, why can't we evaluate an expression in that location?

  • #2
    I too have the same problem, can you let me know if you have found any solution for this thing to work?

    Comment

    Working...
    X