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>
Copy to Clipboard Toggle word wrap

使用 & lt;propertyPlaceholder > 标签使配置更新,例如:

<camelContext ...>
   <propertyPlaceholder id="properties" location="com/mycompany/myprop.properties"/>
</camelContext>
Copy to Clipboard Toggle word wrap

通过位置标签设置属性位置只可以正常工作,但有些情况下,您可以考虑多个资源并从 Camel 2.19.0 开始,您可以使用专用 propertiesLocation 设置属性位置:

<camelContext ...>
  <propertyPlaceholder id="myPropertyPlaceholder">
    <propertiesLocation
      resolver = "classpath"
      path     = "com/my/company/something/my-properties-1.properties"
      optional = "false"/>
    <propertiesLocation
      resolver = "classpath"
      path     = "com/my/company/something/my-properties-2.properties"
      optional = "false"/>
    <propertiesLocation
      resolver = "file"
      path     = "${karaf.home}/etc/my-override.properties"
      optional = "true"/>
   </propertyPlaceholder>
</camelContext>
Copy to Clipboard Toggle word wrap
提示

在 XML
Camel 2.10 中指定 cache
选项支持为 Spring 中的 cache 选项以及 Blueprint XML 指定一个值。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat