【发布时间】:2022-02-05 21:44:29
【问题描述】:
如何检查 Apache Camel 中是否存在属性占位符?
我试过了:
.choice()
.when(simple("{{app.custom.property}}").isNotNull())
...
java.lang.IllegalArgumentException:在来自文本的属性中找不到键 [app.custom.property] 的属性:{{app.custom.property}}
我也试过了(note the ? (question mark) at the beginning of the key name):
.choice()
.when(simple("{{?app.custom.property}}").isNotNull())
...
java.lang.NullPointerException: null
还有(with default value):
.choice()
.when(simple("{{app.custom.property:null}}").isNotNull())
...
它永远不会是
null,因为(如果不存在)它用字符串"null"初始化变量。我可以与这个字符串进行比较,但是我无法知道该属性是否真的存在,或者它是否设置了该值。
【问题讨论】:
标签: java spring-boot apache-camel