国内使用Maven下载失败的解决办法,2021.1 最新版

第一步:版本对应

我使用的是idea2021.1和maven的版本是3.6.3版本,最新的3.6.8版本也测试过,用下面的方法都可以实现。

第二步:下载maven

百度搜索maven下载
在这里插入图片描述
进入官网之后选择下载这个,之后放入指定的路径,进行解压

第三步:进行镜像配置

在刚刚解压的文件夹中找到这个conf文件夹,点击进入
在这里插入图片描述
进去之后选中setting.xml这个文件,使用记事本打开
在这里插入图片描述
划到最下面,找到

	 <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->

这个位置,这个是注释,我们将我们要配置的maven镜像粘贴到他的下面

<mirrors>
    <mirror>
        <!--This sends everything else to /public -->
        <id>aliyun-nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    </mirror>
    <mirror>
        <!--This is used to direct the public snapshots repo in the
            profile below over to a different nexus group -->
        <id>aliyun-nexus-public-snapshots</id>
        <mirrorOf>public-snapshots</mirrorOf>
        <url>http://maven.aliyun.com/nexus/content/repositories/snapshots/</url>
      </mirror>
    </mirrors>

这是我用的阿里云镜像

第四步:设置我们的maven仓库用来存放jar包

在一开始的目录下创建一个maven-repo文件夹
在这里插入图片描述
用来存放我们从远程下载来的jar包,之后再setting.xml中进行配置,将从远程maven仓库中下载的jar包放入到指定的路径。

 <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <localRepository>E:\apache-maven-3.6.3\maven-repo</localRepository>

这个位置大概在上面,主要是找到上面那个注释的位置,然后将代码复制过去,当然这个路劲是我的路径, 你需要将路径改成你自己的路径,路径指向是刚刚创建的maven-repo这个文件夹
这样我们的maven就配置好了

第五步:在idea中使用maven

在这里插入图片描述

第六步:需要在maven中忽略ssl

将一下代码拷贝入import中
在这里插入图片描述

-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

这样maven就设置好了,我们直接创建maven项目可以试一试,或者是创建一个springboot项目。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

最好的文酱

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值