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。

相关推荐
程序员清风几秒前
快手一面:为什么要求用Static来修饰ThreadLocal变量?
java·后端·面试
逍遥德1 分钟前
Java8 Comparator接口 和 List Steam 排序使用案例
java·spring boot·list·排序算法
前行的小黑炭19 分钟前
Android :如何快速让布局适配手机和平板?
android·java·kotlin
_BugMan1 小时前
【IDEA】干活?一个IDEA即可,集成开发平台打造攻略
java·ide·intellij-idea
YA3332 小时前
java设计模式二、工厂
java·开发语言·设计模式
金色天际线-2 小时前
Nginx 优化与防盗链配置指南
java·后端·spring
我爱挣钱我也要早睡!3 小时前
Java 复习笔记
java·开发语言·笔记
AD钙奶-lalala5 小时前
Mac OS上搭建 http server
java
皮皮林5519 小时前
SpringBoot 全局/局部双模式 Gzip 压缩实战:14MB GeoJSON 秒变 3MB
java·spring boot
weixin_456904279 小时前
Spring Boot 用户管理系统
java·spring boot·后端