Maven 安裝 on centos7

本文演示如何在CentOS7上安裝maven。java

#1 準備工做 ###1.1 進入官網下載欄目linux

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

找到下載列表中 Binary tar.gz archive的軟件包地址,以3.5.4版本爲例,地址爲:apache

http://apache.communilink.net/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

###1.2 建立安裝目錄ssh

ssh到安裝maven的主機上,例如192.168.1.101,執行命令:jvm

$ mkdir /usr/local/maven

###1.3 下載軟件包maven

$ wget http://apache.communilink.net/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

#2 安裝maven.net

###2.1 解壓軟件包3d

$ tar -zxvf  apache-maven-3.5.4-bin.tar.gz -C /usr/local/maven

###2.2 設置/etc/profileunix

$ vi /etc/profile
# 在文件結尾加入如下內容
export MAVEN_HOME=/usr/local/maven/apache-maven-3.5.4
export PATH=$PATH:$MAVEN_HOME/bin

###2.3 即時生效code

$ 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>
相關文章
相關標籤/搜索