Spring JNDI查找三元运算符

时间:2017-03-31 10:22:37

标签: java spring jndi

我的网络应用程序中有XML配置。我在这个文件中有以下标记:

<jee:jndi-lookup id="my.super.queue" resource-ref="true" 
     jndi-name="#{ ${my.flag} ? ${jms.my.queue1} : ${jms.my.queue2} }"/>

我们的想法是根据属性中的标志启动队列。但是,似乎jee:jndi不支持三元运算符。我有以下错误:

Error creating bean with name 'my.super.queue': Initialization of bean failed
Property or field 'jms' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public?
<jee:jndi-lookup id="my.super.queue" resource-ref="true" jndi-name="#{ ${my.flag} ? ${jms.my.queue1} : ${jms.my.queue2} }"/>

如何解决?

1 个答案:

答案 0 :(得分:1)

固定。只需要向运营商添加引号'

<jee:jndi-lookup id="my.super.queue" resource-ref="true" 
     jndi-name="#{ ${my.flag} ? '${jms.my.queue1}' : '${jms.my.queue2}' }"/>

这就是全部。谢谢@M。 Denium的灵感。