设置Maven中央仓库 国内镜像 [本地仓库]

wylc123 1年前 ⋅ 339 阅读

目录(?)[-]

  1. ali maven仓库

  2. 其他Maven仓库

https://www.iteblog.com/archives/2022.html

实测可行,,


ali maven仓库

找到 .m2文件夹,新建文件settings.xml,粘贴复制以下代码

C:\Users\当前计算机用户名\.m2

<?xml version="1.0" encoding="utf-8"?><settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localRepository>D:\XXXXXX\_maven_repository_</localRepository>
    <!-- 本地仓库地址,可存放于非C盘 -->


    <pluginGroups>

        <pluginGroup>org.mortbay.jetty</pluginGroup>
    </pluginGroups>

    <proxies>

    </proxies>

    <servers>
        <server>
            <id>releases</id>
            <username>ali</username>
            <password>ali</password>
        </server>
        <server>
            <id>Snapshots</id>
            <username>ali</username>
            <password>ali</password>
        </server>
    </servers>

    <mirrors>
        <mirror>
            <!--This sends everything else to /public -->
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </mirror>
        <mirror>
            <!--This is used to direct the public snapshots repo in the 
          profile below over to a different nexus group -->
            <id>nexus-public-snapshots</id>
            <mirrorOf>public-snapshots</mirrorOf>
            <url>http://maven.aliyun.com/nexus/content/repositories/snapshots/</url>
        </mirror>
    </mirrors>

    <profiles>
        <profile>
            <id>development</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
        <profile>
            <!--this profile will allow snapshots to be searched when activated-->
            <id>public-snapshots</id>
            <repositories>
                <repository>
                    <id>public-snapshots</id>
                    <url>http://public-snapshots</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>public-snapshots</id>
                    <url>http://public-snapshots</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>development</activeProfile>
        <activeProfile>public-snapshots</activeProfile>
    </activeProfiles></settings>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112

然后使用Maven编译你的代码,这时候Maven会从阿里云上面下载Jar依赖,速度明显要比默认的快多了!


其他Maven仓库

我们还可以设置以下的Maven仓库地址,如下:

<mirrors>
    <mirror>
      <id>wso2maven</id>
      <name>wso2 maven</name>
      <url>http://maven.wso2.org/nexus/content/groups/public/</url>
      <mirrorof>central</mirrorof>        
    </mirror></mirrors>12345678

替换上最上面阿里云Maven仓库地址即可。以下的地址也可以使用:

http://maven.wso2.org/nexus/content/groups/public/http://jcenter.bintray.com/http://maven.antelink.com/content/repositories/central/http://maven.springframework.org/release/http://maven.antelink.com/content/repositories/central/http://mavensync.zkoss.org/maven2/http://repository.jboss.com/maven2/http://maven.aliyun.com/nexus/content/groups/publichttp://uk.maven.org/maven2/http://repo1.maven.org/maven2/http://maven.springframework.org/milestonehttp://maven.jeecg.org/nexus/content/repositories/https://repository.apache.org/content/groups/public/https://repository.jboss.org/nexus/content/repositories/releases/   
http://repo.maven.apache.org/maven2https://oss.sonatype.org/content/repositorieshttp://repo.spring.io/release/http://repo.spring.io/snapshot/123456789101112131415161718

end

 

更多内容请访问:IT源点

相关文章推荐

全部评论: 0

    我有话说: