是否可以通过属性文件填充spring util:list?

时间:2013-12-12 22:00:29

标签: spring properties spring-el spelevaluationexception

我想通过属性文件填充传输端点。我尝试了这个,但它不起作用

<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>

在我的属性文件中,我有

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

我收到错误:

  

表达式解析失败;嵌套异常是   org.springframework.expression.spel.SpelEvaluationException:   EL1008E :(位置14):无法找到现场或财产'服务'   'java.util.Properties'

类型的对象

1 个答案:

答案 0 :(得分:2)

我认为SpEL不会为Properties中的属性提供直接字段访问语法。所以我认为正确的语法应该是:

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

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