maven 下载慢,maven 国内镜像

来源:互联网 发布:ubuntu chrome 下载源 编辑:程序博客网 时间:2024/04/29 08:19

maven的默认的中央仓库为:maven.apache.org ,当本地仓库或者自己的maven 私服不存在相关的jar时,如没有特别设置,就去检查maven中央仓库有没有。

由于连接国外网站时网速特慢,为解决这个问题,os china 建立了一个maven 的私服。为了记忆,特将此记录。

settings.xml 设置镜像方法步骤如下: 

1. setting.xml mirrors 设置

修改\apache-maven-3.1.0\conf目录下的setting.xml文件,加入镜像文件地址,setting.xml文件如下所示

[html] view plaincopyprint?
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3.   
  4. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"  
  5.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  6.     xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  
  7.     
  8.     <pluginGroups>  
  9.     </pluginGroups>  
  10.  
  11.     <proxies>  
  12.     </proxies>  
  13.    
  14.     <servers>  
  15.     </servers>  
  16.   
  17.     <mirrors>  
  18.         <mirror>  
  19.             <id>nexus-osc</id>  
  20.             <mirrorOf>central</mirrorOf>  
  21.             <name>Nexus osc</name>  
  22.             <url>http://maven.oschina.net/content/groups/public/</url>  
  23.         </mirror>  
  24.         <mirror>  
  25.             <id>nexus-osc-thirdparty</id>  
  26.             <mirrorOf>thirdparty</mirrorOf>  
  27.             <name>Nexus osc thirdparty</name>  
  28.             <url>http://maven.oschina.net/content/repositories/thirdparty/</url>  
  29.         </mirror>  
  30.     </mirrors>  
  31.    
  32.     <profiles>  
  33.     </profiles>  
  34. </settings>  

2. pom.xml repositories 设置
[html] view plaincopyprint?
  1. <!-- Maven库设置 -->
  2. <repositories>
           <repository>
                 <id>nexus</id>
                 <name>local private nexus</name>
                 <url>http://maven.oschina.net/content/groups/public/</url>
                 <releases>
                     <enabled>true</enabled>
                 </releases>
                 <snapshots>
                     <enabled>false</enabled>
                 </snapshots>
             </repository>
         </repositories>
         <pluginRepositories>
             <pluginRepository>
                 <id>nexus</id>
                 <name>local private nexus</name>
                 <url>http://maven.oschina.net/content/groups/public/</url>
                 <releases>
                     <enabled>true</enabled>
                 </releases>
                 <snapshots>
                     <enabled>false</enabled>
                 </snapshots>
             </pluginRepository>
    </pluginRepositories>


0 1
原创粉丝点击