Linux安装Maven3.6.3版本

发布时间 2024-01-11 17:26:54作者: fanguoan

转自:https://www.cnblogs.com/qq1035807396/p/16422315.html

一、下载

1、进入目录

cd /opt/soft

2、下载

wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

3、解压

tar -zxvf /opt/soft/apache-maven-3.6.3-bin.tar.gz -C /opt/module/

二、安装

1、进入解压目录

cd /opt/module/apache-maven-3.6.3

2、编辑settings配置文件

vim conf/settings.xml

添加阿里云镜像

复制代码
<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>UK</id>
        <name>UK Central</name>
        <url>http://uk.maven.org/maven2</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>
        <id>repo1</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo1.maven.org/maven2/</url>
    </mirror>
    <mirror>
        <id>repo2</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo2.maven.org/maven2/</url>
    </mirror>
复制代码

添加JDK版本

复制代码
<profile>
    <id>jdk1.8</id>
    <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
    </activation>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <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>
复制代码

3、配置环境变量

vim /etc/profile

在文件末尾添加如下内容:

#MAVEN_HOME
export MAVEN_HOME=/opt/module/apache-maven-3.6.3
export PATH=$PATH:$MAVEN_HOME/bin

完成之后刷新

source /etc/profile

4、最后检查是否安装成功