wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip

    创建项目
    mvn archetype:generate -DgroupId=com.tiantian -DartifactId=jxc -DinteractiveMode=false

    linux下安装

    确保每次初始化时,环境变量都正确:
    vim /etc/profile.d/maven.sh
    输入
    #!/bin/bash
    export MAVEN_HOME=/data/maven3
    export PATH=$PATH:$MAVEN_HOME/bin

    保存退出后,为该脚本添加可执行权限:

    chmod 744 /etc/profile.d/maven.sh
    最后执行脚本使环境变量的设置生效:

    source /etc/profile.d/maven.sh

    验证版本

    [root@VM_48_111_centos scripts]# mvn -v
    Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T15:58:13+08:00)
    Maven home: /data/maven3
    Java version: 1.8.0_161, vendor: Oracle Corporation
    Java home: /usr/java/jdk1.8.0_161/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: “linux”, version: “3.10.0-693.5.2.el7.x86_64”, arch: “amd64”, family: “unix”
    如果安装正确就可以看到Maven的版本了。

    替换maven源,阿里云的源:

    打开maven配置文件,比如:

    vi /data/maven3/conf/settings.xml

    找到标签对

    添加后的效果为:

    1. <mirrors> <br /> <mirror> <br /> <id>alimaven</id> <br /> <name>aliyun maven</name> <br /> <url>[http://maven.aliyun.com/nexus/content/groups/public/</url>](http://maven.aliyun.com/nexus/content/groups/public/</url>) <br /> <mirrorOf>central</mirrorOf> <br /> </mirror>
    2. <mirror><br /> <id>repo2</id><br /> <mirrorOf>central</mirrorOf><br /> <name>Human Readable Name for this Mirror.</name><br /> <url>[http://repo2.maven.org/maven2/</url>](http://repo2.maven.org/maven2/</url>)<br /> </mirror><br /> </mirrors>


    d:\usr\local\apache-maven-3.6.2\repo