如何解决Maven速度慢

注:oschina已失效

Maven 远程仓库

    <mirror> <id>ui</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://uk.maven.org/maven2/</url> </mirror> <mirror> <id>ibiblio</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url> </mirror> <mirror> <id>jboss-public-repository-group</id> <mirrorOf>central</mirrorOf> <name>JBoss Public Repository Group</name> <url>http://repository.jboss.org/nexus/content/groups/public/</url> </mirror> <mirror> <id>CN</id> <name>OSChina Central</name> <url>http://maven.oschina.net/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> 

说明:

  1. 上面的地址前面三个只适合maven,sbt的ivy不适合,sbt需要的jar包在里面会找不到,从下面的配置可以看出。
  2. oschina的镜像虽然都适用,但是访问速度真是慢
  3. 最全面的仓库在校园网完全没办法访问

SBT

修改SBT的远程仓库地址有很多办法,这里采用直接修改sbt-lauch.jar/sbt/sbt.boot.properties的方式

[scala]
  version: ${sbt.scala.version-auto} [app] org: ${sbt.organization-org.scala-sbt} name: sbt version: ${sbt.version-read(sbt.version)[0.13.9]} class: ${sbt.main.class-sbt.xMain} components: xsbti,extra cross-versioned: ${sbt.cross.versioned-false} resources: ${sbt.extraClasspath-} [repositories] local Local-Maven-Repository: file:///D:/Java/java-repositories, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext] ibiblio-maven:http://maven.ibiblio.org/maven2/ typesafe-ivy:https://dl.bintray.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext] maven-central uk-repository: http://uk.maven.org/maven2/ jboss-repository: http://repository.jboss.org/nexus/content/groups/public/ [boot] directory: ${sbt.boot.directory-${sbt.global.base-${user.home}/.sbt}/boot/} [ivy] ivy-home: D:/Java/java-repositories checksums: ${sbt.checksums-sha1,md5} override-build-repos: ${sbt.override.build.repos-false} repository-config: ${sbt.repository.config-${sbt.global.base-${user.home}/.sbt}/repositories} 

说明:

  1. repositories 修改远程仓库地址
  2. typesafe-ivy:目的是兼容ivy地址
  3. ivy-home:指的是本地仓库地址,就是jar存在哪里

___________________________________________

在{maven home/conf/settings.xml}中,在<mirror>节点中添加一下镜像

<mirror>

<id>alimaven</id>

<mirrorOf>central<mirrorOf>

<name>aliyun maven</name>

<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>

</mirror>

 

——————————————————————————————

修改  

~/.m2/settings.xml

 

没有此文件需要自行创建个

<settings 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/xsd/settings-1.0.0.xsd"> <localRepository/> <interactiveMode/> <usePluginRegistry/> <offline/> <pluginGroups/> <servers/> <mirrors> <mirror> <id>CN</id> <name>OSChina Central</name> <url>http://maven.oschina.net/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> <proxies/> <profiles/> <activeProfiles/> </settings>


主要是添加mirros

<mirrors>
    <mirror>
      <id>CN</id> <name>OSChina Central</name> <url>http://maven.oschina.net/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>



同时在线查找包  http://maven.oschina.net/  类似maven官网

——————————————————————

/mavenhome/conf/settings.xml


<mirrors>
  
  <mirror>

	<id>alimaven</id>

	<mirrorOf>central<mirrorOf>

	<name>aliyun maven</name>

	<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>

	</mirror>
  
  <mirror>  
      <id>ui</id>  
      <mirrorOf>central</mirrorOf>  
      <name>Human Readable Name for this Mirror.</name>  
      <url>http://uk.maven.org/maven2/</url>  
    </mirror>  
    <mirror>  
      <id>ibiblio</id>  
      <mirrorOf>central</mirrorOf>  
      <name>Human Readable Name for this Mirror.</name>  
      <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>  
    </mirror>  
    <mirror>  
      <id>jboss-public-repository-group</id>  
      <mirrorOf>central</mirrorOf>  
      <name>JBoss Public Repository Group</name>  
      <url>http://repository.jboss.org/nexus/content/groups/public/</url>  
    </mirror>
    <mirror>
      <id>CN</id>
      <name>OSChina Central</name>                                    
      <url>http://maven.oschina.net/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>  
      <id>repo2</id>  
      <mirrorOf>central</mirrorOf>  
      <name>Human Readable Name for this Mirror.</name>  
      <url>http://repo2.maven.org/maven2/</url>  
    </mirror>
    
  <mirror>
  <id>nexus-osc</id> 
  <mirrorOf>*</mirrorOf>
  <name>Nexus osc</name>
  <url>http://maven.oschina.net/content/groups/public/</url>

</mirror> 
  
    <!-- 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>
     -->
  </mirrors>

 

~/.m2/settings.xml

<mirrors>
    <mirror>
        <id>nexus-osc</id>
        <mirrorOf>central</mirrorOf><!--这里指定只屏蔽central仓库-->
        <name>Nexus osc</name>
        <url>http://maven.oschina.net/content/groups/public/</url>
    </mirror>
    <mirror>
        <id>nexus-osc-thirdparty</id>
        <mirrorOf>thirdparty</mirrorOf>
        <name>Nexus osc thirdparty</name>
        <url>http://maven.oschina.net/content/repositories/thirdparty/</url>
    </mirror>


<mirror>  
      <id>ui</id>  
      <mirrorOf>central</mirrorOf>  
      <name>Human Readable Name for this Mirror.</name>  
      <url>http://uk.maven.org/maven2/</url>  
    </mirror>  
    <mirror>  
      <id>ibiblio</id>  
      <mirrorOf>central</mirrorOf>  
      <name>Human Readable Name for this Mirror.</name>  
      <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>  
    </mirror>  
    <mirror>  
      <id>jboss-public-repository-group</id>  
      <mirrorOf>central</mirrorOf>  
      <name>JBoss Public Repository Group</name>  
      <url>http://repository.jboss.org/nexus/content/groups/public/</url>  
    </mirror>
    <mirror>
      <id>CN</id>
      <name>OSChina Central</name>                                    
      <url>http://maven.oschina.net/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>  
      <id>repo2</id>  
      <mirrorOf>central</mirrorOf>  
      <name>Human Readable Name for this Mirror.</name>  
      <url>http://repo2.maven.org/maven2/</url>  
    </mirror>
    
    </mirrors>

 

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值