我的网络应用程序中有 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} }"/>
如何解决?
最佳答案
已修复。只需要在运算符中添加引号 '
即可:
<jee:jndi-lookup id="my.super.queue" resource-ref="true"
jndi-name="#{ ${my.flag} ? '${jms.my.queue1}' : '${jms.my.queue2}' }"/>
仅此而已。谢谢@M。 Denium 的灵感。
关于java - Spring JNDI-查找三元运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43138322/