Linux 安装 Maven 3.5.4

1,125 阅读1分钟

一、maven下载

1、官方手动下载

https://maven.apache.org/download.cgi

2、直接下载

更新yum命令:apt-get install yum 
安装wget命令:yum install wget
下载Maven命令:wget https://archive.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

二、安装与部署

1、maven 解压
# maven 解压
tar zvxf apache-maven-3.5.4-bin.tar.gz
# 把maven转换到指定目录
mv apache-maven-3.5.4 /home/
2、修改配置文件
# 打开全局配置文件
vim /etc/profile# 
添加maven全局配置参数
export MAVEN_HOME=/home/apache-maven-3.5.4/
export PATH=$MAVEN_HOME/bin:$PATH
# 让配置文件生效
source /etc/profile
3、查询是否成功
# 查询maven版本号
mvn --version

4、修改settings.xml 配置

# 阿里云仓库地址
<mirror>
    <id>alimaven</id>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
</mirror>
# JDK版本
<profile>
    <id>jdk8</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>