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 开始,您可以使用专用属性Location 设置属性位置:

<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 中的
缓存选项支持为 Spring 内的缓存选项和 Blueprint XML 指定值。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat