You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot ≥1.5.20兼容的Spring Cloud组件版本咨询

兼容版本推荐与问题解决

针对Spring Boot ≥1.5.20的场景,以下是经过验证的兼容版本组合,同时解决你遇到的两个核心问题:

一、正确的依赖版本组合

直接使用以下版本,确保Spring Boot、Spring Cloud、Stream Kafka Binder和Azure Event Hubs之间的兼容性:

  • Spring Boot: 1.5.22.RELEASE
  • Spring Cloud: Edgware.SR6(这是适配Boot 1.5.x的最后一个稳定Spring Cloud版本分支)
  • Spring Cloud Stream Kafka Binder: 1.3.4.RELEASE
  • Spring Cloud Azure Event Hubs: 1.1.0.RELEASE

为什么这个组合可行?

你最初遇到的NoClassDefFoundError: ConfigurableCompositeMessageConverter,是因为高版本的Spring Cloud Stream Kafka Binder(如3.0.1)依赖的Spring Integration版本过高,而Spring Boot 1.5.x内置的Spring Integration版本并不包含这个类。Edgware分支的Spring Cloud与Boot 1.5.x完全对齐,对应的Stream Kafka Binder 1.3.4.RELEASE依赖的Spring Integration版本与Boot 1.5.22兼容。

二、解决ZooKeeper连接拒绝问题

你使用1.1.0版本时出现的ZooKeeper连接问题,本质是配置缺失导致客户端默认尝试连接本地ZooKeeper,而Azure Event Hubs的Kafka API不需要依赖ZooKeeper。需要补充以下关键配置:

调整后的application.yaml:

spring:
  cloud:
    azure:
      auto-create-resources: true
      credential-file-path: my.azureauth
      eventhub:
        checkpoint-storage-account: azuremigrationv2
        namespace: somenamespace
        region: Central US
        resource-group: some-rg
    stream:
      bindings:
        consumer:
          destination: event-hub-1
          group: testconsumergroup
          content-type: application/json
          nativeEncoding: true
      consumer:
        concurrency: 1
        valueSerde: JsonSerde
        requeue-rejected: true
      # 新增Kafka相关配置,指向Azure Event Hubs的Kafka端点
      kafka:
        binder:
          bootstrap-servers: ${spring.cloud.azure.eventhub.namespace}.servicebus.windows.net:9093
          configuration:
            security.protocol: SASL_SSL
            sasl.mechanism: PLAIN
            sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="你的Event Hubs连接字符串";

配置说明:

  1. bootstrap-servers:格式为{Event Hubs命名空间}.servicebus.windows.net:9093,替换成你的实际命名空间。
  2. SASL认证配置:Azure Event Hubs的Kafka API要求使用SASL_SSL认证,sasl.jaas.config里的密码是Event Hubs的连接字符串(可以从Azure门户获取)。

这样配置后,客户端会直接连接Azure Event Hubs的Kafka端点,不再尝试连接本地ZooKeeper,解决连接拒绝的问题。

内容的提问来源于stack exchange,提问作者java_geek

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 14:13:11