Eclipse下,修改MAVEN 中央仓库地址,解决maven下载慢问题


eclipse中修改maven中央仓库:2种方式

方式1:(已测试)

作用于所有工作空间:

1、逐项打开:eclipse->preference->Maven->User Settings。按窗口中的User Settings文本框显示的路径,创建settings.xml文件,或修改路径后创建文件。

2、关闭窗口后重新打开,点击“open file”,在IDE中打开该配置文件,出现“could not read settings.xml”不必管。

3、复制下列内容至配置文件,其中<mirror></mirror>部分为国内镜像。

  1. <settings xsi:schemaLocation=“http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd”>  
  2.     <mirrors>  
  3.         <!– mirror | Specifies a repository mirror site to use instead of a given   
  4.             repository. The repository that | this mirror serves has an ID that matches   
  5.             the mirrorOf element of this mirror. IDs are used | for inheritance and direct   
  6.             lookup purposes, and must be unique across the set of mirrors. | –>  
  7.          <mirror>  
  8.             <id>alimaven</id>  
  9.             <name>aliyun maven</name>  
  10.             <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
  11.             <mirrorOf>central</mirrorOf>  
  12.           </mirror>  
  13.           
  14.           <mirror>   
  15.             <id>uk</id>    
  16.             <mirrorOf>central</mirrorOf>    
  17.             <name>Human Readable Name for this Mirror.</name>    
  18.             <url>http://uk.maven.org/maven2/</url>   
  19.           </mirror>  
  20.           
  21.            <mirror>  
  22.             <id>CN</id>  
  23.             <name>OSChina Central</name>  
  24.             <url>http://maven.oschina.net/content/groups/public/</url>  
  25.             <mirrorOf>central</mirrorOf>  
  26.           </mirror>  
  27.           
  28.           <mirror>  
  29.             <id>nexus</id>  
  30.             <name>internal nexus repository</name>  
  31.             <url>http://repo.maven.apache.org/maven2</url>  
  32.             <mirrorOf>central</mirrorOf>  
  33.           </mirror>  
  34.     </mirrors>  
  35.   
  36.     <profiles>  
  37.         <profile>  
  38.             <id>default</id>  
  39.             <repositories>  
  40.                 <repository>  
  41.                     <id>nexus</id>  
  42.                     <name>local private nexus</name>  
  43.                     <url>http://maven.oschina.net/content/groups/public/</url>  
  44.                     <releases>  
  45.                         <enabled>true</enabled>  
  46.                     </releases>  
  47.                     <snapshots>  
  48.                         <enabled>false</enabled>  
  49.                     </snapshots>  
  50.                 </repository>  
  51.             </repositories>  
  52.             <pluginRepositories>  
  53.                 <pluginRepository>  
  54.                     <id>nexus</id>  
  55.                     <name>local private nexus</name>  
  56.                     <url>http://maven.oschina.net/content/groups/public/</url>  
  57.                     <releases>  
  58.                         <enabled>true</enabled>  
  59.                     </releases>  
  60.                     <snapshots>  
  61.                         <enabled>false</enabled>  
  62.                     </snapshots>  
  63.                 </pluginRepository>  
  64.             </pluginRepositories>  
  65.         </profile>  
  66.     </profiles>  
  67. </settings>  
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <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>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
          </mirror>

          <mirror> 
            <id>uk</id>  
            <mirrorOf>central</mirrorOf>  
            <name>Human Readable Name for this Mirror.</name>  
            <url>http://uk.maven.org/maven2/</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>nexus</id>
            <name>internal nexus repository</name>
            <url>http://repo.maven.apache.org/maven2</url>
            <mirrorOf>central</mirrorOf>
          </mirror>
    </mirrors>

    <profiles>
        <profile>
            <id>default</id>
            <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>
        </profile>
    </profiles>
</settings>

4、”apply”后配置生效,重新编译即可。




猜你喜欢

转载自blog.csdn.net/YP_W_Ricardo/article/details/80095976