IntelliJ无法搜索添加Maven依赖问题求助(Ultimate版/JDK17)
解决IntelliJ Ultimate中Maven依赖搜索失败的方案
刷新并更新Maven仓库索引
- 打开IntelliJ设置(Windows/Linux:Ctrl+Alt+S;Mac:Cmd+,),导航到
Build, Execution, Deployment > Build Tools > Maven > Repositories - 选中当前使用的仓库,点击
Update按钮触发索引刷新,等待索引同步完成后重试依赖搜索 - 若默认仓库索引更新慢,可在Maven用户配置文件(
Settings > Maven > User Settings File对应路径)中添加国内镜像,示例配置:
配置完成后点击工具栏的<mirrors> <mirror> <id>aliyunmaven</id> <mirrorOf>central</mirrorOf> <url>https://maven.aliyun.com/repository/public</url> </mirror> </mirrors>Reload All Maven Projects按钮刷新项目
检查IntelliJ的Maven导入配置
- 进入
Settings > Build, Execution, Deployment > Build Tools > Maven > Importing,确保勾选Automatically download: Sources和Automatically download: Documentation - 检查
VM options for importer中是否存在影响网络的代理参数,如有多余配置可临时移除 - 重启IntelliJ后重新打开项目,再尝试搜索依赖
确认JDK与Maven的兼容性
- 打开项目结构窗口(Ctrl+Alt+Shift+S),在
Project Settings > Project中设置Project SDK为Oracle OpenJDK 17 - 进入
Settings > Build, Execution, Deployment > Build Tools > Maven > Runner,将JRE设置为与项目一致的OpenJDK 17,避免版本不匹配导致依赖解析异常
重置本地Maven仓库索引
- 关闭IntelliJ,找到本地Maven仓库下的
.index文件夹(通常路径为~/.m2/repository/.index),删除该文件夹内所有文件 - 重新启动IntelliJ,等待Maven自动重建索引,完成后再次尝试搜索依赖
内容的提问来源于stack exchange,提问作者user24487302
相关产品推荐
相关产品推荐

