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。

相关推荐
Forget the Dream34 分钟前
Spring AI 2.0 系列(四):Starter 与 OpenAI-compatible:一个不绑死厂商的模型环境
java·人工智能·spring·springai
波波烤鸭38 分钟前
曾经离不开的 IDE,AI 来了还剩什么
ai·intellij-idea·idea·jb
GoodStudyAndDayDayUp39 分钟前
Mermaid 流程图基础语法
java·服务器·流程图
dadaobusi39 分钟前
学习:noc死锁
java·服务器·前端
旋风菠萝42 分钟前
ThreadLocalMap 的 key 使用弱引用?
java
圆心角44 分钟前
前端转 Java 全栈:依赖、入口、路由、中间件到底放哪
java·spring boot·后端
Rain的Java大神之路1 小时前
别再背"512+64"了:RAG 分块策略深度剖析,从原理到 Java 生产实现
java·后端·ai编程
hudd6681 小时前
JavaEE 初阶 - 网络编程(第二部分:网络编程套接字)
java·开发语言·网络·java-ee
xcLeigh1 小时前
Go入门:逻辑运算符与短路求值机制
android·java·golang·go·教程