263.22. 桥接 Spring 和 Camel 属性占位符

可从 Camel 2.10 开始

Spring 框架不允许 Apache Camel 等第三方框架无缝 hook 到 Spring 属性占位符机制。但是,您可以通过声明类型为 org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer 类型的 Spring Bean 来轻松桥接 Spring org.springframework.beans.factory.config.PropertyPlaceholderConfigurer 类型。

要桥接 Spring 和 Camel,您必须定义一个 bean,如下所示:

桥接 Spring 和 Camel 属性占位符

您不能 同时使用 spring <context:property-placeholder> 命名空间,这是不可能的。

在声明此 bean 后,您可以使用 Spring 风格来定义属性占位符,以及 <camelContext> 标签中的 Camel 风格,如下所示:

使用网桥属性占位符

注意 hello bean 如何使用 ${ } 表示法的纯 Spring 属性占位符。在 Camel 路由中,我们使用 {{ 和 }} 的 Camel 占位符表示法。