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>
通过位置标签设置属性位置只可以正常工作,但有些情况下,您可以考虑多个资源并从 Camel 2.19.0 开始,您可以使用专用 propertiesLocation 设置属性位置:
提示
在 XML
Camel 2.10 中指定 cache选项支持为 Spring 中的 cache 选项以及 Blueprint XML 指定一个值。