Spring Boot、Spring Cloud与Spring Cloud AWS版本兼容问题咨询
根据Spring Cloud发布列车文档,Spring Boot 3.3.1应可与Spring Cloud 2023.0.2搭配使用,同时引入Spring Cloud AWS v3.2.0-M1后,启动时出现如下错误:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'compositeCompatibilityVerifier' defined in class path resource [org/springframework/cloud/configuration/CompatibilityVerifierAutoConfiguration.class]: Failed to instantiate [org.springframework.cloud.configuration.CompositeCompatibilityVerifier]: Factory method 'compositeCompatibilityVerifier' threw exception with message: Spring Cloud/ Spring Boot version compatibility checks have failed: [[VerificationResult@56ec31ca description = 'Spring Boot [3.3.1] is not compatible with this Spring Cloud release train', action = 'Change Spring Boot version to one of the following versions [3.2.x] .
You can find the latest Spring Boot versions here [https://spring.io/projects/spring-boot#learn].
If you want to learn more about the Spring Cloud Release train compatibility, you can visit this page [https://spring.io/projects/spring-cloud#overview] and check the [Release Trains] section.
If you want to disable this check, just set the property [spring.cloud.compatibility-verifier.enabled=false]']]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636)
请问该版本组合为何无法正常工作?是文档有误、代码问题还是我遗漏了某些配置?
错误原因
官方发布列车文档的兼容性说明是准确的,既不是文档错误,也不是你遗漏了配置,问题出在Spring Cloud AWS v3.2.0-M1这个预发布版本上:
- Spring Cloud 2023.0.2(代号Leyton)本身确实兼容Spring Boot 3.3.x,但Spring Cloud AWS的这个里程碑版本内部依赖的兼容性校验逻辑尚未更新,仍然只允许Spring Boot 3.2.x版本,因此启动时触发了错误的版本拦截。
解决方案
提供三种可行处理方式:
- 升级Spring Cloud AWS:等待Spring Cloud AWS发布支持Spring Boot 3.3.x的正式版或更新的里程碑版本,替换当前的v3.2.0-M1。
- 临时禁用兼容性校验:在配置文件中添加配置项
spring.cloud.compatibility-verifier.enabled=false,跳过版本检查逻辑。注意这只是临时方案,可能隐藏潜在的兼容性风险,不推荐长期使用。 - 降级Spring Boot版本:将Spring Boot版本回退到3.2.x系列,完全匹配兼容性校验规则要求的版本范围,确保所有组件依赖一致。
内容的提问来源于stack exchange,提问作者Keith Bennett

