Results 1 to 2 of 2

Thread: Expressions in an import tag

  1. #1
    Join Date
    May 2006
    Posts
    2

    Default 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. #2
    Join Date
    Jan 2010
    Posts
    3

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •