264.9. 在 Spring XML 中配置
Spring XML 提供了两种配置变体。您可以将 spring bean 定义为 PropertiesComponent,它类似于 Java DSL 中完成的方式。或者,您可以使用 < propertyPlaceholder> 标签。
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
<property name="location" value="classpath:com/mycompany/myprop.properties"/>
</bean>
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
<property name="location" value="classpath:com/mycompany/myprop.properties"/>
</bean>
使用 & lt;propertyPlaceholder > 标签会使配置更加全新的,例如:
<camelContext ...> <propertyPlaceholder id="properties" location="com/mycompany/myprop.properties"/> </camelContext>
<camelContext ...>
<propertyPlaceholder id="properties" location="com/mycompany/myprop.properties"/>
</camelContext>
通过 location 标签设置属性位置可以正常工作,但有些资源需要考虑并从 Camel 2.19.0 开始,您可以使用专用 propertiesLocation 设置属性位置:
提示
在 XML
Camel 2.10 中指定 cache 选项支持在 Spring 和 Blueprint XML 中为 cache 选项指定一个值。