bean 'spring.sleuth.baggage-keys' 已经定义

bean 'spring.sleuth.baggage-keys' already defined

我正在将应用程序从 Spring Boot 1.x 升级到 Spring Boot 2.x。当我尝试 运行 一个现有的(和以前工作的)单元测试时,我看到了以下输出:

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'spring.sleuth.baggage-keys', defined in class path resource [org/springframework/cloud/sleuth/autoconfig/brave/BraveBaggageConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/sleuth/autoconfig/TraceBaggageConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

我的 Gradle 项目使用以下实现:'org.springframework.cloud:spring-cloud-sleuth-core:2.2.8.RELEASE'

我尝试与 the Gradle dependencies task to make sure there were no conflicting versions of spring-cloud-sleuth-core and friends. I also looked at and this post 联系,但他们没有解决我的问题。

我需要避免覆盖 bean,目前我的部署目标被限制为 Spring Boot 2。4.x。

检查 compatibility matrix,您应该使用 Spring Cloud 2020。0.x aka Ilford (Sleuth 3.x) 和 Spring Boot 2.4(或 2.5) ).

Sleuth 2.2.8 是 Spring Cloud Hoxton,它与 Boot 2.4 不兼容。