这里查找最新版本 http://maven.apache.org/download.cgi

下载安装包


1
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
解压



1
tar -zxvf apache-maven-3.6.3-bin.tar.gz
配置maven环境



1
2
3
4
vi /etc/profile
 
# maven
export MAVEN_HOME=上一步解压的目录 export PATH=$MAVEN_HOME/bin:$PATH

重新加载配置文件


1
source /etc/profile

修改MAVEN配置文件MAVEN_HOME/conf/settings.xml:1.设置本地仓库地址 2.引用国内镜像以及个人私服 3.指定JDK


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?xml version="1.0" encoding="UTF-8"?>
 
    <pluginGroups>
    </pluginGroups>
    <!-- 配置jar包下载路径 linux需要更改为/目录开头的linux目录 -->
    <localRepository>本地仓库目录</localRepository>
    <proxies>
    </proxies>
    <servers>
    </servers>
    <!-- 从阿里云镜像下载jar包 -->
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
 
    <!-- 指定jdk1.8 -->
    <profiles>
        <profile>
            <id>jdk1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
 
            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
    </profiles>
</settings>