服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Java教程 - 解决IDEA无法下载maven依赖的问题

解决IDEA无法下载maven依赖的问题

2020-09-04 13:52stephenChen946 Java教程

这篇文章主要介绍了解决IDEA无法下载maven依赖的问题,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

今天新建一个springboot项目时,项目建好后,在IDEA下载依赖包时,下载了很久都没有下载完,后来仔细一看,是下载不了。

解决IDEA无法下载maven依赖的问题

解决方法:

在项目的pom.xml文件上右键,弹出框中选择maven,再选择open 'settings.xml'  或者是 create 'settings.xml' ,操作如图:

解决IDEA无法下载maven依赖的问题

在该文件中填入如下内容:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>nexus</id>
      <name>internal nexus repository</name>
      <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
      <url>http://repo.maven.apache.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
 
</settings>

重新右键pom.xml文件,选择 maven ,选择 Reimport 即可下载依赖。操作步骤及settings.xml文件内容如图:

解决IDEA无法下载maven依赖的问题

settings.xml文件内容:

解决IDEA无法下载maven依赖的问题

至此,依赖依法下载的问题已经解决。。

疑惑:将settings.xml文件中的<mirrors>替换成如下内容,竟然也无法下载依赖(但看网上博客说会让下载速度变快的)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<mirrors>
 <!-- mirror
  | Specifies a repository mirror site to use instead of a given repository. The repository that
  | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
  | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
  |
 <mirror>
  <id>mirrorId</id>
  <mirrorOf>repositoryId</mirrorOf>
  <name>Human Readable Name for this Mirror.</name>
  <url>http://my.repository.com/repo/path</url>
 </mirror>
  -->
 
 <mirror>
  <id>alimaven</id>
  <name>aliyun maven</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  <mirrorOf>central</mirrorOf>
 </mirror>
 
 <mirror>
  <id>uk</id>
  <mirrorOf>central</mirrorOf>
  <name>Human Readable Name for this Mirror.</name>
  <url>http://uk.maven.org/maven2/</url>
 </mirror>
 
 <mirror>
  <id>CN</id>
  <name>OSChina Central</name>
  <url>http://maven.oschina.net/content/groups/public/</url>
  <mirrorOf>central</mirrorOf>
 </mirror>
 
 <mirror>
  <id>nexus</id>
  <name>internal nexus repository</name>
  <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
  <url>http://repo.maven.apache.org/maven2</url>
  <mirrorOf>central</mirrorOf>
 </mirror>
 
 </mirrors>

原文链接:https://blog.csdn.net/steven_zhulin/article/details/90724983

延伸 · 阅读

精彩推荐