我正在将一个应用程序从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确认一下,以确保spring-cloud-sleuth-core和friends没有冲突的版本。我还研究了this post和this post,但它们并没有解决我的问题。
我需要避免重写bean,并且我的部署目标目前只能使用Spring Boot 2.4.x。
发布于 2021-11-16 11:35:29
检查compatibility matrix,你应该使用Spring Cloud 2020.0.x (Sleuth 3.x)和Spring Boot2.4(或2.5)。
Sleuth 2.2.8是Spring Cloud Hoxton,它与Boot 2.4不兼容。
https://stackoverflow.com/questions/69994509
复制相似问题