Loading

配置maven镜像仓库

下载解压
https://maven.apache.org/download.cgi

tar xvfz apache-maven-3.9.6-bin.tar.gz
mv apache-maven-3.9.6 /usr/local/maven-3.9.6

配置环境变量

vim /etc/profile.d/my_env.sh
export MAVEN_HOME=/usr/local/maven-3.9.6
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH

加载环境变量

source /etc/profile
echo $PATH
mvn -v

进入maven目录 修改settings.xml

vim /opt/apache-maven-3.8.5/conf/settings.xml

<mirrors>
    <mirror>
        <id>alimaven</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>
    <mirror>
        <id>alimaven</id>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>
        <id>central</id>
        <name>Maven Repository Switchboard</name>
        <url>http://repo1.maven.org/maven2/</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>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>google-maven-central</id>
        <name>Google Maven Central</name>
        <url>https://maven-central.storage.googleapis.com
        </url>
        <mirrorOf>central</mirrorOf>
    </mirror>

    <!-- 中央仓库在中国的镜像 -->
    <mirror>
        <id>maven.net.cn</id>
        <name>oneof the central mirrors in china</name>
        <url>http://maven.net.cn/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
<mirrors>
[root@znjc-ds-zcfwserv conf]# grep -C 10 '中央仓库在中国的镜像' settings.xml 
        <url>http://repository.jboss.org/nexus/content/groups/public</url>
    </mirror>
    <mirror>
        <id>google-maven-central</id>
        <name>Google Maven Central</name>
        <url>https://maven-central.storage.googleapis.com
        </url>
        <mirrorOf>central</mirrorOf>
    </mirror>

    <!-- 中央仓库在中国的镜像 -->
    <mirror>
        <id>maven.net.cn</id>
        <name>oneof the central mirrors in china</name>
        <url>http://maven.net.cn/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>

posted @ 2022-08-05 15:03  萝卜青菜~  阅读(817)  评论(0编辑  收藏  举报