配置选项

Spring Cloud Stream 支持常规配置选项以及绑定和绑定器的配置。 某些绑定器允许其他绑定属性支持特定于中间件的功能。spring-doc.cadn.net.cn

可以通过 Spring Boot 支持的任何机制向 Spring Cloud Stream 应用程序提供配置选项。 这包括应用程序参数、环境变量以及 YAML 或 .properties 文件。spring-doc.cadn.net.cn

关于使用 Spring/Boot 核心属性注释的注意事项。

无论您处理的是公共属性还是绑定/绑定器特定属性,有时您可能需要依赖核心 Spring 和 Boot 核心属性注释,例如@Value@ConditionalOnProperty.对于这种情况,请确保指定 属性的全名。 例如,给定当前的 application.yamlspring-doc.cadn.net.cn

my:
  prop: foo
spring:
  application:
    name: "messaging-test"
  cloud:
    function:
      definition: "produce;consume"
    stream:
      binders:
        rabbit:
          environment:
            my:
              prop: bar

如果要注入my.prop从根目录使用@Value注释,则使用(@Value("${my.prop}") String someProperty).如果你想要特定于 binder 上下文的那个,那么你可以指定 完整的属性名称(@Value(“${spring.cloud.stream.binders.rabbit.environment.my.prop}") String someProperty)同样的道理@ConditionalOnProperty在那里你会有效地做同样的事情。spring-doc.cadn.net.cn