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

Spring Boot项目添加Maven依赖后ApplicationContext仍无法识别如何解决

修复方案
  • 移除手动引入的spring-context依赖
    spring-boot-starter已经内置了spring-context组件,Spring Boot父依赖会统一管理版本,无需单独指定。修改后的依赖配置如下:
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
  • 刷新Maven依赖
    IDEA用户可点击右侧Maven面板的刷新图标,或右键项目选择 Maven > Reload Project;Eclipse用户右键项目选择 Maven > Update Project。
  • 校验类导入路径
    确认代码中导入的ApplicationContext全限定名为:
import org.springframework.context.ApplicationContext;
  • 强制重新构建
    如果仍未解决,可在项目根目录执行命令mvn clean compile,强制清理旧构建产物并重新拉取依赖编译。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.26 02:24:02