springpropertiesspring-elspelevaluationexception

Is it possible to populate spring util:list via properties file?


I would like to populate transport End points via properties file. I tried this but it didn't work

<util:properties id="cxfProperties" location="/WEB-INF/classes/cxf.properties" />

<util:list id="transportEndpoints">
    <!--
    <value>http://localhost:8080/doubleit/services/doubleit.*</value>
    -->
    <value>#{cxfProperties.service.wsdllocation}</value>
</util:list>

In my properties file I have

service.wsdllocation=http://localhost:8080/doubleit/services/doubleit.*

I get error:

Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 14): Field or property 'service' cannot be found on object of type 'java.util.Properties'


Solution

  • I don't think SpEL provides direct field access syntax for property in Properties. So I think the correct syntax should be:

    #{cxfProperties.getProperty('service.wsdllocation')}
    

    or

    #{cxfProperties.getProperty('service.wsdllocation', 'SOME_DEFAULT_VAL')}