Idea 下载不了源码 cannot download source

一、打开Terminal (Alt+F12),找到项目具体模块所在的文件夹,输入一下指令

bash 复制代码
mvn dependency:resolve -Dclassifier=sources

如果你的idea 终端无法使用mvn指令,要配置你idea中的maven的环境变量:

1、找到maven在idea中的位置,在你idea安装目录下的\plugins\maven

2、接下来配置环境变量:在你的用户变量,特别注意是用户变量中创建Path,然后将 你idea安装目录+\plugins\maven\lib\maven3\bin 复制进去

然后,重启Idea

二、如果你执行第一步时 下载时: Download from central 从中心仓库下载很慢,pom中添加如下:

复制代码
  <repositories>
        <repository>
            <id>aliyun</id>
            <url>https://maven.aliyun.com/repository/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>aliyun-plugin</id>
            <url>https://maven.aliyun.com/repository/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

pom中更换阿里云仓库时不要忽略了pluginRepositories,原来,只有项目本身的依赖,走了aliyun这个repository,maven命令需要的插件(比如clean、install都是maven的插件),走的还是默认的repository。

相关推荐
呱牛do it4 小时前
企业级门户网站设计与实现:基于SpringBoot + Vue3的全栈解决方案(Day 3)
java·vue
神の愛5 小时前
左连接查询数据 left join
java·服务器·前端
南境十里·墨染春水6 小时前
linux学习进展 线程同步——互斥锁
java·linux·学习
雨奔6 小时前
Kubernetes 联邦 Deployment 指南:跨集群统一管理 Pod
java·容器·kubernetes
杨凯凡6 小时前
【021】反射与注解:Spring 里背后的影子
java·后端·spring
lulu12165440786 小时前
Claude Code项目大了响应慢怎么办?Subagents、Agent Teams、Git Worktree、工作流编排四种方案深度解析
java·人工智能·python·ai编程
riNt PTIP6 小时前
SpringBoot创建动态定时任务的几种方式
java·spring boot·spring
老星*7 小时前
AI选股核心设计思路
java·ai·开源·软件开发
それども7 小时前
Comparator.comparing 和 拆箱问题
java·jvm
星晨羽8 小时前
西门子机床opc ua协议实现变量读写及NC文件上传下载
java·spring boot