如何通过在yaml文件中设置spring来关闭kafka的azure事件中心

问题描述 投票:0回答:1

我尝试过这个,但没有帮助

春天: 自动配置: 排除: - org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration - org.springframework.boot.actuate.autoconfigure.metrics.KafkaMetricsAutoConfiguration - org.springframework.cloud.stream.config.BindingsEndpointAutoConfiguration - org.springframework.cloud.stream.config.ChannelBindingAutoConfiguration - org.springframework.cloud.stream.config.ChannelsEndpointAutoConfiguration - org.springframework.cloud.stream.config.BindersHealthIndicatorAutoConfiguration

azure azure-eventhub
1个回答
0
投票

有时,即使您将

spring.kafka.consumer.enabled
spring.kafka.producer.enabled
设置为
false
,Kafka 组件也会由 Spring Boot 自动配置。更明确地说,您可以在主应用程序类中排除
KafkaAutoConfiguration
类。

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;

@SpringBootApplication(exclude = KafkaAutoConfiguration.class)
public class YourApplication {
    public static void main(String[] args) {
        SpringApplication.run(YourApplication.class, args);
    }
}
  • 您可以为 Spring Boot 启用调试日志记录以查看正在进行的自动配置。在你的
    application.yaml
    (或
    application.properties
logging:
  level:
    org.springframework.boot.autoconfigure: DEBUG
  • 如果您在应用程序配置中禁用了 Kafka 并确认它不是自动配置的,并且您在 Azure 门户或 Azure CLI 中看不到 Kafka 相关的设置或事件中心

使用此命令签入 Azure eventhub 命名空间 -

az eventhubs eventhub list --resource-group <resource-group-name> --namespace-name <namespace-name>

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.