264.22. 桥接 Spring 和 Camel 属性占位符
从 Camel 2.10 开始提供
Spring Framework 不允许 Apache Camel 等第三方框架将 hook 无缝到 Spring 属性占位符机制中。但是,您可以通过声明类型为 org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer
的 Spring bean 来轻松地桥接 Spring 和 Camel,它是一个 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 占位符表示法。