Announcement Announcement Module
Collapse
No announcement yet.
can't use systemProperties, elvis operator together in util:properties in Spring 3.1? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • can't use systemProperties, elvis operator together in util:properties in Spring 3.1?

    Hi,

    I am trying to declare a Properties bean that would source local properties from:
    a) location specified by
    Code:
    config-location
    system property - if such property is present, else from
    b) default-config.properties found in classpath

    Seems like this should work...
    Code:
    <util:properties id="cfgProps"
        location="#{systemProperties['config-location'] ?: classpath:default-config.properties}" />
    ..but am getting this exception instead. What am I doing incorrectly?

    Caused by: org.springframework.expression.spel.SpelParseExcep tion: EL1041Epos 43): After parsing a valid expression, there is still more data in the expression: 'colon('
    at org.springframework.expression.spel.standard.Inter nalSpelExpressionParser.doParseExpression(Internal SpelExpr essionParser.java:118)
    at org.springframework.expression.spel.standard.SpelE xpressionParser.doParseExpression(SpelExpressionPa rser.jav a:56)
    at org.springframework.expression.spel.standard.SpelE xpressionParser.doParseExpression(SpelExpressionPa rser.jav a:1)
    at org.springframework.expression.common.TemplateAwar eExpressionParser.parseExpressions(TemplateAwareEx pression Parser.java:128)

  • #2
    duh. answer is wrap default value in single quotes ;-

    Code:
    <util:properties id="cfgProps"
        location="#{systemProperties['config-location'] ?: 'classpath:default-config.properties'}" />

    Comment

    Working...
    X