mvn 换源

张映 发表于 2018-12-18

分类目录: java/android

标签:, ,

maven的默认镜像,有的时候,下载jar包的非常的慢。换了阿里镜像速度快了很多。

1,查找maven的配置文件

MacBook-Pro:conf zhangying$ mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec  //maven home路径
Java version: 1.8.0_112, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"

mac,centos都可以通过查看版本的方式来查找路径,其他linux应当一样。

2,配置settings.xml

$ cd /usr/local/Cellar/maven/3.5.0/libexec/conf
$ cp settings.xml settings.xml_bak
$ vim setting.xml //将mirrors改成如下内容
<mirrors>
<mirror>
 <id>aliyun-public</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun public</name>
 <url>https://maven.aliyun.com/repository/public</url>
</mirror>

<mirror>
 <id>aliyun-central</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun central</name>
 <url>https://maven.aliyun.com/repository/central</url>
</mirror>

<mirror>
 <id>aliyun-spring</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun spring</name>
 <url>https://maven.aliyun.com/repository/spring</url>
</mirror>

<mirror>
 <id>aliyun-spring-plugin</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun spring-plugin</name>
 <url>https://maven.aliyun.com/repository/spring-plugin</url>
</mirror>

<mirror>
 <id>aliyun-apache-snapshots</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun apache-snapshots</name>
 <url>https://maven.aliyun.com/repository/apache-snapshots</url>
</mirror>

<mirror>
 <id>aliyun-google</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun google</name>
 <url>https://maven.aliyun.com/repository/google</url>
</mirror>

<mirror>
 <id>aliyun-gradle-plugin</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun gradle-plugin</name>
 <url>https://maven.aliyun.com/repository/gradle-plugin</url>
</mirror>

<mirror>
 <id>aliyun-jcenter</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun jcenter</name>
 <url>https://maven.aliyun.com/repository/jcenter</url>
</mirror>

<mirror>
 <id>aliyun-releases</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun releases</name>
 <url>https://maven.aliyun.com/repository/releases</url>
</mirror>

<mirror>
 <id>aliyun-snapshots</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun snapshots</name>
 <url>https://maven.aliyun.com/repository/snapshots</url>
</mirror> 

<mirror>
 <id>aliyun-grails-core</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun grails-core</name>
 <url>https://maven.aliyun.com/repository/grails-core</url>
</mirror>

<mirror>
 <id>aliyun-mapr-public</id>
 <mirrorOf>*</mirrorOf>
 <name>aliyun mapr-public</name>
 <url>https://maven.aliyun.com/repository/mapr-public</url>
</mirror>
</mirrors>


转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/android/2002.html

留下评论

留下评论
  • (必需)
  • (必需) (will not be published)
  • (必需)   2X6=?