1 准备工作
1.1 进入官网下载栏目
http://maven.apache.org/download.cgi
找到下载列表中 Binary tar.gz archive的软件包地址,以3.5.4版本为例,地址为:
http://apache.communilink.net/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
1.2 创建安装目录
ssh到安装maven的主机上,例如192.168.1.101,执行命令:
$ mkdir /usr/local/maven
1.3 下载软件包
$ wget http://apache.communilink.net/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
2 安装maven
2.1 解压软件包
$ tar -zxvf apache-maven-3.5.4-bin.tar.gz -C /usr/local/maven
2.2 设置/etc/profile
$ vi /etc/profile
# 在文件结尾加入以下内容
export MAVEN_HOME=/usr/local/maven/apache-maven-3.5.4
export PATH=$PATH:$MAVEN_HOME/bin
2.3 即时生效
$ source /etc/profile
2.4 查看安装情况
$ mvn -v
如果安装成功,会显示:
Apache Maven 3.5.4 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T03:49:05+08:00)
Maven home: /usr/local/maven/apache-maven-3.5.4
Java version: 1.8.0_161, vendor: OpenJDK
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.2-1.el7.elrepo.x86_64", arch: "amd64", family: "unix"
2.5 设置本地maven仓库
打开配置文件setting.xml,修改本地maven仓库的路径:
$ vi $MAVEN_HOME/conf/settings.xml
# 设置本地maven仓库的路径
<localRepository>/var/lib/maven/repo</localRepository>
你现在的气质里,藏着你走过的路,读过的书,爱过的人。