加速我们的maven下载速度

        现在maven开发已是主潮流,默认情况下,我们创建一个maven工程会在C盘自动生成一个maven仓库,只是我们从官网下载的maven包中的settings.xml文件配置默认用的是国际仓库,导致我们新建一个maven工程后下载包的速度非常非常慢,让人难以忍受,因此我们迫切需要提升maven的下载速度,这时使用阿里提供的镜像地址便是不错的选择。

       首先我们从官网下载maven开发包,maven当前最新的版本是3.3.9,大家也可以到:http://download.csdn.net/detail/u012453843/9770164这个地址进行下载。

       下面我们需要修改一下maven的settings.xml文件,只需做两处修改即可。

        1.指定本地仓库的位置,(前提是我在E盘的根目录下新建了一个名叫m2的文件夹)如下红色粗体字所示。

<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">
  <!-- 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:\m2\repository</localRepository>
  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

         2.添加阿里云的镜像

<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>CN</id>
<name>OSChina Central</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

  </mirrors>

           经过以上两步,我们便可以将我们的maven下载速度提升100倍左右!

           使用IntellijIDEA作为开发工具的话,应该怎样配置maven呢?下面使用图例说明。

           1.点击File----->Settings...如下图所示。


        2.我们在弹出的框中的搜索框内输入maven搜索出maven,点击它会看到下图右侧的内容,我们勾选"Always update snapshots"前面的复选框,"Maven home directory"我们选择我们maven解压包所在的位置。"User settings file"就选择我们改过的settings.xml文件。"Local Repository"就选择我们在本地创建的仓库位置。设置完之后点击"Apply"和"OK"这时我们的maven将是今非昔比了,下载速度成百倍的提升!


  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值