美文网首页Maven专题
Maven 设置阿里云中央仓库的settings.xml

Maven 设置阿里云中央仓库的settings.xml

作者: 小波同学 | 来源:发表于2022-07-13 16:58 被阅读0次

    Maven 中央仓库地址大全

    1、阿里中央仓库(首推1)

    <repository>
        <id>aliyun</id>
        <name>aliyun maven Repository</name>
        <url>https://maven.aliyun.com/repository/public</url>
    </repository>
    

    2、camunda.com 中央仓库(首推2)

    <repository>
        <id>activiti-repos2</id>
        <name>Activiti Repository 2</name>
        <url>https://app.camunda.com/nexus/content/groups/public</url>
    </repository>
    

    3、spring.io 中央仓库

    <repository>
        <id>springsource-repos</id>
        <name>SpringSource Repository</name>
        <url>http://repo.spring.io/release/</url>
    </repository>
    

    4、maven.apache.org 中央仓库

    <repository>
        <id>central-repos</id>
        <name>Central Repository</name>
        <url>http://repo.maven.apache.org/maven2</url>
    </repository>
    

    5、maven.org 中央仓库

    <repository>
        <id>central-repos1</id>
        <name>Central Repository 2</name>
        <url>http://repo1.maven.org/maven2/</url>
    </repository>
    

    6、alfresco.com 中央仓库(首推3)

    <repository>
        <id>activiti-repos</id>
        <name>Activiti Repository</name>
        <url>https://maven.alfresco.com/nexus/content/groups/public</url>
    </repository>
    

    7、oschina 中央仓库(需要翻墙)

    <repository>
        <id>oschina-repos</id>
        <name>Oschina Releases</name>
        <url>http://maven.oschina.net/content/groups/public</url>
    </repository>
    

    8、oschina thinkgem 中央仓库(需要翻墙)

    <repository> 
        <id>thinkgem-repos</id> 
        <name>ThinkGem Repository</name>
        <url>http://git.oschina.net/thinkgem/repos/raw/master</url>
    </repository>
    

    9、java.net 中央仓库(需要翻墙)

    <repository>
        <id>java-repos</id>
        <name>Java Repository</name>
        <url>http://download.java.net/maven/2/</url>
    </repository>
    

    10、github.com 中央仓库(需要翻墙)

    <repository> 
        <id>thinkgem-repos</id> 
        <name>ThinkGem Repository 2</name>
        <url>https://raw.github.com/thinkgem/repository/master</url>
    </repository>
    

    11、ibiblio 镜像地址(这个也比较快)

    <mirror>
        <id>ibiblio</id>
        <name>Mirror from Maven ibiblio</name>
        <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    

    12、repo1.maven.apache.org 镜像地址

    <mirror>
        <id>central</id>
        <name>Maven Repository Switchboard</name>
        <url>http://repo1.maven.apache.org/maven2/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    

    13、repo2 镜像地址

    <mirror>
        <id>repo2</id>
        <name>Mirror from Maven Repo2</name>
        <url>http://repo2.maven.org/maven2/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    

    14、UK 镜像地址

    <mirror>
        <id>uk central</id>
        <name>Mirror from UK</name>
        <url>http://uk.maven.org/maven2/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    

    15、JBoos 镜像地址

    <mirror>
        <id>jboss-public-repository-group</id>
        <name>JBoss Public Repository Group</name>
        <url>http://repository.jboss.org/nexus/content/groups/public</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    

    16、Google 镜像地址

    <mirror>
        <id>google</id>
        <name>google maven</name>
        <url>https://maven.google.com/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    

    17、Maven china镜像地址

    <mirror>
        <id>maven.net.cn</id>
        <name>Mirror from Maven in china</name>
        <url>http://maven.net.cn/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    

    settings.xml配置

    <?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">
    
        <!-- 默认的值是${user.home}/.m2/repository -->
        <localRepository>E:\apache\repository</localRepository>
    
        <!-- 如果Maven要试图与用户交互来得到输入就设置为true,否则就设置为false,默认为true。 -->
        <interactiveMode>true</interactiveMode>
    
        <!-- 如果Maven使用${user.home}/.m2/plugin-registry.xml来管理plugin的版本,就设置为true,默认为false。 -->
        <usePluginRegistry>false</usePluginRegistry>
    
        <!-- 如果构建系统要在离线模式下工作,设置为true,默认为false。 如果构建服务器因为网络故障或者安全问题不能与远程仓库相连,那么这个设置是非常有用的。 -->
        <offline>false</offline>
    
        <mirrors>
            <mirror>
                <id>aliyunmaven</id>
                <mirrorOf>*</mirrorOf><!--*代表所有的jar包都到阿里云下载-->
                <!--<mirrorOf>central</mirrorOf>--><!--central代表只有中央仓库的jar包才到阿里云下载-->
                <name>阿里云公共仓库</name>
                <url>https://maven.aliyun.com/repository/public</url>
            </mirror>
    
            <!--老版阿里云公共仓库-->
            <!--
            <mirror>
                <id>nexus-aliyun</id>
                <mirrorOf>central</mirrorOf>
                <name>Nexus aliyun</name>
                <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            </mirror>
            -->
            
            <!-- 中央仓库在中国的镜像 -->
            <mirror>
                <id>maven.net.cn</id>
                <name>Mirror from Maven in china</name>
                <url>http://maven.net.cn/content/groups/public/</url>
                <mirrorOf>central</mirrorOf>
            </mirror>
        </mirrors>
    
    
    
    
        <!-- settings.xml中的profile是pom.xml中的profile的简洁形式。 它包含了激活(activation),仓库(repositories),插件仓库(pluginRepositories)和属性(properties)元素。 
            profile元素仅包含这四个元素是因为他们涉及到整个的构建系统,而不是个别的POM配置。 如果settings中的profile被激活,那么它的值将重载POM或者profiles.xml中的任何相等ID的profiles。 -->
        <profiles>
            <profile>
                <id>default</id>
                <activation>
                    <activeByDefault>true</activeByDefault>
                    <jdk>1.8</jdk>
                </activation>
                <!-- 远程仓库-->
                <repositories>
                    <!-- 阿里云远程仓库-->
                    <repository>
                        <id>aliyun</id>
                        <name>aliyun maven Repository</name>
                        <url>https://maven.aliyun.com/repository/public</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                    </repository>
                    <repository>
                        <id>spring-milestone</id>
                        <name>Spring Milestone Repository</name>
                        <url>http://repo.spring.io/milestone</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                        <layout>default</layout>
                    </repository>
                    <repository>
                        <id>spring-snapshot</id>
                        <name>Spring Snapshot Repository</name>
                        <url>http://repo.spring.io/snapshot</url>
                        <releases>
                            <enabled>false</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                        <layout>default</layout>
                    </repository>
                </repositories>
                <!-- 镜像,添加了会先从阿里云仓库下载-->
                <pluginRepositories>
                    <pluginRepository>
                        <id>aliyun-plugin</id>
                        <url>https://maven.aliyun.com/repository/public</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                    </pluginRepository>
                </pluginRepositories>
            </profile>
        </profiles>
        <!-- activations是profile的关键,就像POM中的profiles,profile的能力在于它在特定情况下可以修改一些值。 
            而这些情况是通过activation来指定的。 -->
        <!-- <activeProfiles/> -->
    
    </settings>
    

    参考:
    https://blog.csdn.net/wtl1992/article/details/121314010

    http://t.zoukankan.com/larryzeal-p-6149086.html

    相关文章

      网友评论

        本文标题:Maven 设置阿里云中央仓库的settings.xml

        本文链接:https://www.haomeiwen.com/subject/viltirtx.html