首页 > 解决方案 > Spring Cloud Bus Kafka Bean 配置

问题描述

我不太喜欢在我的配置中使用 application.yml 或 bootstrap.yml。

您知道任何可以用作 bean 以配置以下属性的类吗?

spring:
  cloud:
    bus:     
      enabled: true
    stream:
      kafka:
        binder:
          zkNodes: localhost:9092
          brokers: localhost:2181

我的目标是得到这样的东西:

@Configuration
public class myConfiguration {

  @Bean
  public Object myCloudBusConfig() {
    Object config = new Object();
    config.setCloudBusEnabled(true);
    return config;
  }

}

此外,作为未来的参考(可能更棘手),我如何确定/找到哪些类引用特定属性?属性名称和源包之间是否存在关联?

这对我有很大帮助:)

标签: javaspringspring-cloudspring-cloud-streamspring-cloud-config

解决方案


推荐阅读