将maven源改为国内阿里云镜像

由于众所周知的原因,maven的库在中国大陆非常慢。我在百度上搜到的大部分文章都是直接在~/.m2/setting.xml 加入以下内容

  <mirrors>
    <mirror>
    <id>aliyunmavenid>
    <mirrorOf>centralmirrorOf>
    <name>aliyun mavenname>
    <url>https://maven.aliyun.com/repository/public url>
    mirror>
  mirrors>

其实这样设置,我发现其实镜像并没有改变,还是maven的中央库。在maven 库的官网上http://maven.apache.org/settings.html,是建议我们这样设置的。

<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/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <mirrors>
    <mirror>
    <id>aliyunmavenid>
    <mirrorOf>centralmirrorOf>
    <name>aliyun mavenname>
    <url>https://maven.aliyun.com/repository/public url>
    mirror>
  mirrors>
  <proxies/>
  <profiles/>
  <activeProfiles/>
settings>

或者这样

<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>aliyunmavenid>
    <mirrorOf>centralmirrorOf>
    <name>aliyun mavenname>
    <url>https://maven.aliyun.com/repository/public url>
    mirror>
  mirrors>
settings>

这样设置之后,我发现maven库确实改成了阿里云库。

你可能感兴趣的:(将maven源改为国内阿里云镜像)