263.20. 将 .cfg 或 .properties 文件用于 Blueprint 属性占位符

可从 Camel 2.10.4 开始

当使用 Blueprint XML 文件中的 Blueprint 属性占位符时,您可以在 .properties.cfg 文件中声明属性。如果您使用 Apache ServieMix / Karaf,则该容器具有从 etc/pid.cfg 的 etc/pid.cfg 的 etc 目录中加载属性的惯例,其中 pidpersistence-id

例如,在蓝图 XML 文件中,我们具有 persistence-id="stuff",这意味着它将把配置文件加载为 etc/stuff.cfg

现在,如果要单元测试这个蓝图 XML 文件,您可以覆盖 loadConfigAdminConfigurationFile,并告知 Camel 哪个文件载入如下:

请注意,此方法需要返回值为 2 值的 String[]。1st 值是加载的配置文件的路径。2nd 值是 < cm:property-placeholder> 标签的 persistence- id

stuff.cfg 文件只是一个纯文本文件,其属性占位符如下:

== this is a comment
greeting=Bye