我需要在文件内搜索字符串,我使用了下面的java代码搜索字符串,它按我的预期工作,
.when(body().convertToString().contains("mytext"))
如果我需要更改搜索字符串,我必须再次重新编译代码,所以我尝试从属性文件加载搜索字符串,如下所示
我在属性文件中定义了 findme='mytext'
但不会搜索带有“properties:{{findme}}”的字符串
.when(body().convertToString().contains("properties:{{findme}}"))
最佳答案
我认为应该是:
.when(body().convertToString().contains("{{findme}}"))
来自Apache Camel documentation on properties :
Syntax
The syntax to use Camel's property placeholder is to use
{{key}}
for example{{file.uri}}
where file.uri is the property key. You can use property placeholders in parts of the endpoint URI's which for example you can use placeholders for parameters in the URIs.
关于java - Camel .contains() 不从属性文件中搜索值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41693710/