264.20. 将 .cfg 或 .properties 文件用于 Blueprint 属性占位符
从 Camel 2.10.4 开始提供
当在 Blueprint XML 文件中使用 Blueprint 属性占位符时,您可以在 .properties
或 .cfg
文件中声明属性。如果您使用 Apache ServieMix / Karaf,则此容器有惯例,它从 etc 目录中的一个文件加载属性,其使用命名 etc/pid.cfg
,其中 pid
是 persistence-id
。
例如,在蓝图 XML 文件中,我们具有 persistence-id="stuff"
,这意味着它将作为 etc/stuff.cfg
加载配置文件。
现在,如果要单元测试这个蓝图 XML 文件,您可以覆盖 loadConfigAdminConfigurationFile
,并告诉 Camel 要载入哪个文件,如下所示:
请注意,此方法需要返回具有 2 值的 String[]
。第 1st 值是要加载的配置文件的路径。2nd 值是 < cm:property-placeholder> 标签的
。
persistence-
id
material .cfg
文件只是带有属性占位符的普通属性文件,例如:
== this is a comment greeting=Bye