maven更换阿里云中央仓库镜像

由于maven默认设置的是指向国外的中央仓库,所以下载的时候会很慢,甚至有时候卡住不动。所以如果想让maven快速的下载相关的jar包,可以将地址设置成阿里云的中央仓库镜像,下边介绍如何更改maven的中央仓库地址设置成阿里云的中央仓库镜像

  1. 打开本地maven的conf文件夹,打开settiongs.xml
    在这里插入图片描述
  2. 找到mirrors的标签,在里边添加这一段
	<!-- 阿里云中央仓库 -->
    <mirror>
        <id>nexus-aliyun</id>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        <mirrorOf>central</mirrorOf>
    </mirror>

在这里插入图片描述
3. 创建一个pom.xml文件,然后再当前文件目录进入dom界面,输入mvn clean install,出现下边的链接表示设置成功

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xn.maven</groupId>
  <artifactId>tmaven</artifactId>
  <packaging>jar</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>tmaven</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <!-- 下载Spring-4.2.17 -->
  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.2.17.RELEASE</version>
    </dependency>
  </dependencies>

</project>

在这里插入图片描述
或者使用第二个方法,还是在maven的setting.xml中找到repositories标签,并在里面添加下面的内容,记得保存

        <repository>
            <id>aliyunmaven</id>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </repository>

在这里插入图片描述
测试方法在上边,然后就体验奔放的速度了

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值