Maven 迁移local repository

1.1 Maven仓库主要有2种:

  • remote repository:相当于公共的仓库,大家都能访问到,一般可以用URL的形式访问,一般默认的地址:http://search.maven.org/

  • local repository:存放在本地磁盘的一个文件夹,例如,windows上默认是C:\Users\{用户名}\.m2\repository目录

1.2 Remote Repository主要有3种:

  • 中央仓库:http://repo1.maven.org/maven2/ 

  • 私服:内网自建的maven repository,其URL是一个内部网址 

  • 其他公共仓库:其他可以互联网公共访问maven repository,例如 jboss repository等

repository里存放的都是各种jar包和maven插件。当向仓库请求插件或依赖的时候,会先检查local repository,如果local repository有则直接返回,否则会向remote repository请求,并缓存到local repository。

也可以把做的东西放到本地仓库,仅供本地使用;或上传到远程仓库,供大家使用。 

================================

我用的是idea自带的maven3

下载安装idea以后,最好先配置一些maven的环境变量,有一些操作要在cmd中进行

idea中的maven路径为:

D:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\plugins\maven\lib\maven3

在环境变量中配置

MAVEN_HOME,变量值就是上面的路径

再在Path中添加

%MAVEN_HOME%\bin;

这样maven就配置好了。

maven默认的仓储位置是C:\Users\Administrator\.m2

资源全放系统盘,万一要重装系统呢?现在切换到D盘

打开配置文件,位置为%MAVEN_HOME%/conf/setting.xml,maven_home可以查看idea中的maven设置

打开setting.xml,修改配置信息

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ~/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
<localRepository>D:\360CloudUI\maven\repository</localRepository>

最后就是把这个setting.xml配置文件覆盖掉idea中默认的配置

一切ok,再把原来C盘中的repository资源迁移到新的位置就可以了。

===================================================================

maven 镜像配置成国内的

同样是在上面的setting.xml中进行配置

  <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.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>net-cn</id>      
          <mirrorOf>central</mirrorOf>      
          <name>Human Readable Name for this Mirror.</name>      
          <url>http://maven.net.cn/content/groups/public/</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>JBossJBPM</id>  
          <mirrorOf>central</mirrorOf>  
          <name>JBossJBPM Repository</name>  
          <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>  
    </mirror>  
         <mirror>      
          <id>antelink</id>  
          <mirrorOf>central</mirrorOf>  
          <name>antelink Repository</name>  
          <url>http://maven.antelink.com/content/repositories/central/</url>  
    </mirror>  
    <mirror>      
          <id>openkoala</id>  
          <mirrorOf>central</mirrorOf>  
          <name>openkoala Repository</name>  
          <url>http://nexus.openkoala.org/nexus/content/groups/Koala-release/</url>  
    </mirror>  
    <mirror>      
          <id>tmatesoft</id>  
          <mirrorOf>central</mirrorOf>  
          <name>tmatesoft Repository</name>  
          <url>http://maven.tmatesoft.com/content/groups/public/</url>  
    </mirror>  
    <mirror>      
          <id>mavensync</id>  
          <mirrorOf>central</mirrorOf>  
          <name>mavensync Repository</name>  
          <url>http://mavensync.zkoss.org/maven2/</url>  
    </mirror>  
  </mirrors>

阿里云的

  <mirror>
       <id>alimaven</id>
       <name>aliyun maven</name>
       <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
       <mirrorOf>central</mirrorOf>        
     </mirror>

http://blog.csdn.net/jiuqiyuliang/article/details/45390313

https://my.oschina.net/fdblog/blog/546938

http://www.tuicool.com/articles/VRJ3qui

http://zhidao.baidu.com/link?url=9M9KLKNfeTU8gqRBA3sCbwD6HkZZ_PpzxaGZJpgBBnTLNf5bddxtnCn3HusnydRDHwlsFMcnm6eDz2ii0ebV_w59Cd-anw-B4KdIGFQnK5q

https://my.oschina.net/sunchp/blog/100634

 

posted @ 2016-09-23 14:16  hongdada  阅读(6981)  评论(0编辑  收藏  举报