1. Download maven
Open Maven official website download page: http://maven.apache.org/download.cgi
Download: apache-maven-3.5.0-bin.tar.gz
Unzip the downloaded installation package to a directory, for example:/users/yuanweipeng/documents/maven
2. Configure Environment variables
- Open Terminel to enter the following command:
vim ~/.bash_profile
To open a. bash_profile file, add a command to set environment variables in the secondary file
export M2_HOME=/Users/yuanweipeng/Documents/maven/apache-maven-3.5.0
export PATH=$PATH:$M2_HOME/bin
After the addition is saved and launched, execute the following command to make the configuration effective:
source ~/.bash_profile
3. Check if the configuration is in effect
1, enter: Mvn-v command, enter as follows:
Apache Maven3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426;2017-04-04T03:39:06+08:(XX) MavenHome/users/yuanweipeng/documents/maven/apache-maven-3.5.0java version: 1.8.0_121, vendor:oracle corporationjava home: /library/java/javavirtualmachines/jdk1 .8.0_121.jdk/contents/home/jredefault LOCALE:ZH_CN, platform encoding:utf -8os name: "Mac OS X", version: " 10.12.6 ", arch: "x86_64", family: "Mac"
The configuration succeeds.
Installing and configuring Maven under Mac OS x