java项目依赖管理如果用了maven就so easy,但是maven默认连接国外的maven源,非常慢,最近几天试着用了不同的源,总结一下
1. 使用内网源
如果公司内部有靠谱的源,用内网速度最快了,没的说,but 如果内网源不给力,就悲剧了
2. os china 源
os china 貌似曾经是国内最好的maven源,but现在http://maven.oschina.net/help.html这个网站反正我是打不开,但是网上铺天盖地的都是推荐这个是最好用的国内源,坑我花了很多时间,还是不能用
3. 国内最好用的maven源 阿里云的maven源
阿里云的maven源比较低调,我也是从知乎上看到的
nexus-aliyun
*
Nexus aliyun
http://maven.aliyun.com/nexus/content/groups/public
4. 国外源
- 包速查:http://maven.outofmemory.cn
- 参考:http://lychie.github.io/pages/articles/maven/15041621.html
- maven官方 http://repo1.maven.org/maven2/
或 http://repo2.maven.org/maven2/ (延迟低一些)
settings.xml 配置远程仓库镜像
ibiblio.org
central
mirrors repositories from central
http://mirrors.ibiblio.org/pub/mirrors/maven2
常见maven源
name | url |
---|---|
测试网速 | https://asm.ca.com/en/ping.php |
USA California(美国加利福尼亚) | http://repo1.maven.org/maven2 |
United Kingdom(英国) | http://uk.maven.org/maven2 |
USA,North Carolina(美国北卡罗莱纳州) | http://mirrors.ibiblio.org/pub/mirrors/maven2 |
France(法国) | http://maven.antelink.com/content/repositories/central |
soft | http://maven.tmatesoft.com/content/groups/public |
52.1.120.131 | repo.scala-sbt.org |
54.165.44.236 | repo.typesafe.com |
54.243.161.21 | typesafe.com |
54.192.134.21 | downloads.typesafe.com |
sbt源的配置
参考
sbt运行时经常需要下载大量的jar包,默认连接到maven官网,速度通常比较慢。
在~/.sbt/
下添加一个repositories
文件,里面内容如下:
[repositories]
local
osc: http://maven.oschina.net/content/groups/public/
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-oss-releases
maven-central
sonatype-oss-snapshots
参考
编译spark
设置SBT的repository代理
在Spark源码目录的project/plugins.sbt中可以看到默认的repository的地址:
resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases/"
但是这几个地址在天朝访问速度是在太慢,于是想办法设置代理源。经过一番查询,发现可以创建文件~/.sbt/repository,内容如下:
[repositories]
local
local-maven:file:///home/mz/.m2/repository
repo2:http://repo2.maven.org/maven2/
ivy-typesafe:http://dl.bintray.com/typesafe/ivy-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
ivy-sbt-plugin:http://dl.bintray.com/sbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
这里设置本地的maven库和一些其他的库地址,其中后面两个地址是ivy的库,所以要在后面加上ivy库路径解析方法。
设置了repository,再使用sbt下载依赖仍然是无比的慢,应该是全局的repository代理无法覆盖设置,需要在SBT_OPTS中加上:
-Dsbt.override.build.repos=true
这样就不会使用project/plugins.sbt中定义的库了。
国外镜像
ibiblio.org
ibiblio
central
ibiblio Mirror of http://repo1.maven.org/maven2/ http://mirrors.ibiblio.org/pub/mirrors/maven2/
jboss
jboss-public-repository-group
central
JBoss Public Repository Group
http://repository.jboss.org/nexus/content/groups/public
repo2
repo2
central
Human Readable Name for this Mirror.
http://repo2.maven.org/maven2/
uk.maven.org
ui
central
Human Readable Name for this Mirror.
http://uk.maven.org/maven2/
国内镜像
oschina.net
nexus-osc
*
Nexus osc
http://maven.oschina.net/content/groups/public/
net.cn
net-cn
central
Human Readable Name for this Mirror.
http://maven.net.cn/content/groups/public/