1. 程式人生 > >CentOS下安裝與配置Maven

CentOS下安裝與配置Maven

export http utf uri 阿裏 cor redhat odin ngs

安裝Maven

當前系統

[root@141 ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

下載 http://maven.apache.org/download.cgi

wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.tar.gz

安裝

mkdir -p /opt/maven
tar -xzvf apache-maven-3.5.3-bin.tar.gz -C /opt/maven/
ln -s /opt/maven/apache-maven-3.5.3 /usr/local/maven
echo 'export M2_HOME=/usr/local/maven' >> /etc/profile
echo 'export PATH=$M2_HOME/bin:$PATH' >> /etc/profile
source /etc/profile
mvn -v

配置Maven:使用國內鏡像

使用阿裏鏡像,在用戶配置文件.m2/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">
    <mirrors>
        <mirror>
            <id>CN</id>
            <name>hhlt Central</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
</settings>

CentOS下安裝與配置Maven