搜索

146.3. 定义 Bean

download PDF

除了创建 Camel Main 提供的 Bean 的一般支持外,YAML DSL 提供了便捷的语法来定义和配置它们:

- beans:
  - name: beanFromMap  1
    type: com.acme.MyBean 2
    properties: 3
      foo: bar

其中,

1
将实例绑定到 Camel Registry 的 bean 名称。
2
bean 的完全限定类名称
3
要设置的 bean 的属性

可以使用映射或属性样式定义 bean 的属性,如下例所示:

- beans:
  # map style
  - name: beanFromMap
    type: com.acme.MyBean
    properties:
      field1: 'f1'
      field2: 'f2'
      nested:
        field1: 'nf1'
        field2: 'nf2'
  # properties style
  - name: beanFromProps
    type: com.acme.MyBean
    properties:
      field1: 'f1_p'
      field2: 'f2_p'
      nested.field1: 'nf1_p'
      nested.field2: 'nf2_p'
注意

Bean 元素仅用作 root 元素。

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.