Linux系统下安装Maven

本例子以apache-maven-3.5.2版本为例, 官网下载地址:Maven Download

  • 下载Maven
cd /usr/lib
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.zip
unzip apache-maven-3.5.2-bin.zip
rm -rf apache-maven-3.5.2-bin.zip
  • 配置 Maven 环境 vim /etc/profile, 在文件末尾加上如下配置
export MAVEN_HOME=/usr/lib/apache-maven-3.5.2
export PATH=${PATH}:${MAVEN_HOME}/bin
  • 配置生效 . /etc/profile, 检查Maven 是否成功安装 mvn -v
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T00:58:13-07:00)
Maven home: /usr/lib/apache-maven-3.5.2
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-514.el7.x86_64", arch: "amd64", family: "unix"
  • 修改默认配置 vim /usr/lib/apache-maven-3.5.2/conf/settings.xml
  • 修改默认仓库 ${MAVEN_HOME}/.m2/repository
  • 配置国内的源, 在标签里添加
    
      nexus-aliyun
      *
      Nexus aliyun
      http://maven.aliyun.com/nexus/content/groups/public
    

    
     nexus-osc
     *
     Nexusosc
     http://maven.oschina.net/content/groups/public/
    
  • 修改JDK版本, 在里添加
  
    jdk1.8
    
        true
        1.8
    
    
        1.8
        1.8
        1.8
    
   

你可能感兴趣的:(Linux系统下安装Maven)