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

SpringBoot应用启动失败:ApplicationContext初始化错误求助

问题解决:Spring Boot 依赖版本不兼容导致启动失败

核心原因

你遇到的int org.springframework.util.ObjectUtils.hashCode(boolean)方法不存在错误,本质是版本完全不匹配:

  • spring-core 6.0.9 属于 Spring Framework 6.x 系列,必须搭配 Spring Boot 3.x 版本使用
  • spring-boot-autoconfigure 1.2.1.RELEASE 是老旧的 Spring Boot 1.x 组件,和 Spring Framework 6.x 没有兼容性

具体修复步骤

1. 用 Spring Boot 父依赖统一版本(推荐最优方案)

在pom.xml中添加 Spring Boot 父依赖,让它自动管理所有相关组件的版本,彻底避免手动指定版本引发的冲突:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <!-- 选择与 Spring Framework 6.x 兼容的 Spring Boot 3.x 版本,示例用 3.1.2 -->
    <version>3.1.2</version>
    <relativePath/>
</parent>

添加后,移除所有手动指定版本的 Spring 相关依赖(包括 spring-core、spring-boot-autoconfigure 等),由父依赖统一管控版本。

2. 手动对齐依赖版本(无父依赖场景)

如果无法使用父依赖,手动调整所有 Spring 组件版本:

  • 删除 spring-boot-autoconfigure 1.2.1.RELEASE 的依赖声明
  • 确保 spring-core 及其他 Spring 依赖均使用与 Spring Boot 3.x 匹配的版本(如 Spring Framework 6.0.x 系列)

3. 清理本地仓库并重建项目

执行以下命令清理本地 Maven 仓库中的冲突缓存,再重新构建:

mvn clean install -U

额外注意点

  • Spring Boot 3.x 要求 JDK 版本至少为 17,请确认项目使用的 JDK 符合要求
  • 检查自行添加的第三方依赖,确保它们与 Spring Boot 3.x 兼容,避免依赖传递引入旧版本 Spring 组件

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 09:47:04