admin管理员组文章数量:1794759
Maven:解决IDEA无法下载源码
问题
通过点击进IDEA反编译的代码文件处下载源代码Sources: IDEA提示报错,无法下载源代码:
解决办法一、下载全部依赖的源码 mvn dependency:resolve是解决项目的所有依赖项,它将打印出已解决依赖项的详细信。指定可选参数classifier=sources,将尝试分析下载对应的依赖的源代码。打开Teminal,使用本地的Maven执行,然后在下载就有了。
mvn dependency:resolve -Dclassifier=sources二、按需下载 先去确认 IDEA 的 File | Settings | Build, Execution, Deployment | Build Tools | Maven设置,Maven版本是3.8.4,配置文件也是3.8.4的,本地Maven仓库也有设置。 再次尝试下载源代码,如果失败,去查看本地的Maven仓库有没有一个后缀为sources.jar.lastUpdated的文件,这个文件是Maven尝试下载源代码但是失败了的记录文件。 使用notepad++打开该文件,根据里面的内容,看来无法下载是和这个maven-default-http-blocker有很大的关系。
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice. #Sun Nov 21 16:52:48 CST 2021 http\\://0.0.0.0/.error=Could not transfer artifact org.slf4j\\:slf4j-api\\:jar\\:sources\\:1.7.21 from/to maven-default-http-blocker (http\\://0.0.0.0/)\\: Blocked mirror for repositories\\: [nexus-aliyun (http\\://maven.aliyun/nexus/content/groups/public, default, releases)] @default-maven-default-http-blocker-http\\://0.0.0.0/.lastUpdated=1637484768579查看setting.xml文件,找到了以下相关的配置,上面说是这个maven-default-http-blocker阻碍了去阿里的镜像库查找依赖,注释掉这个maven-default-http-blocker的镜像,并且最好多找几个镜像加上去,可以防止一些镜像没有某个依赖导致报错。 保存后重启IDEA
常用镜像 <!-- 阿里镜像 --> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>maven.aliyun/nexus/content/repositories/central/</url> </mirror> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>maven.aliyun/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>central</id> <name>Maven Repository Switchboard</name> <url>repo1.maven/maven2/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>repo2.maven/maven2/</url> </mirror> <mirror> <id>ibiblio</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>mirrors.ibiblio/pub/mirrors/maven2/</url> </mirror> <mirror> <id>jboss-public-repository-group</id> <mirrorOf>central</mirrorOf> <name>JBoss Public Repository Group</name> <url>repository.jboss/nexus/content/groups/public</url> </mirror> <mirror> <id>google-maven-central</id> <name>Google Maven Central</name> <url>maven-central.storage.googleapis </url> <mirrorOf>central</mirrorOf> </mirror> <!-- 中央仓库在中国的镜像 --> <mirror> <id>maven</id> <name>oneof the central mirrors in china</name> <url>maven/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror>版权声明:本文标题:Maven:解决IDEA无法下载源码 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686527666a78049.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论