Spring Cloud Streams在Spring Boot >=2.4.0版本下Supplier方法缺失问题求助
问题根因
该错误属于典型的Spring生态组件版本不匹配问题:
- 你当前使用的
com.azure.spring:azure-spring-cloud-stream-binder-eventhubs:2.8.0仅适配Spring Boot 2.3.x版本,对应的Spring Cloud版本为Hoxton系列 - Spring Boot 2.4.0+对应的Spring Cloud版本升级为2020.0.x(Ilford)系列,其中Spring Integration的API发生了变更,旧版binder调用的
IntegrationFlows.from(Supplier)方法在新版Spring Integration中已经被移除,因此抛出方法不存在的异常
适配方案
- 统一Spring全家桶版本依赖
首先引入Spring Cloud版本管理,若使用Maven,在<dependencyManagement>节点中添加如下配置:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>2020.0.3</version> <type>pom</type> <scope>import</scope> </dependency>
将Spring Boot版本锁定为2.4.5,和经过验证的兼容版本对齐,避免出现其他版本冲突问题。
升级Azure Event Hub binder适配版本
将com.azure.spring:azure-spring-cloud-stream-binder-eventhubs的版本升级到3.x系列,可使用3.1.0及以上适配Spring Boot 2.4.x和Spring Cloud 2020.0.x的版本,该版本的binder已经适配了新版Spring Integration的API,不会再出现方法不存在的报错。(可选)排查残留依赖冲突
如果升级完成后仍然有报错,可以执行依赖树命令检查是否存在多个版本的Spring Integration相关jar包:
- Maven排查命令:
mvn dependency:tree | grep spring-integration - Gradle排查命令:
gradlew dependencies | grep spring-integration
如果发现有低版本的spring-integration-core被传递引入,可以在对应依赖中手动排除低版本,确保所有Spring Integration相关依赖的版本统一为Spring Boot 2.4.5自带的5.4.x版本即可。
内容的提问来源于stack exchange,提问作者user518066
相关产品推荐
相关产品推荐

