1、下载Maven
Maven官网下载页面:http://maven.apache.org/download.cgi
清华的镜像:apache-maven-3.6.0-bin.tar.gz
解压后可以放到其他目录,本人是在用户文档目录下新建的Java文件夹存放
2、配置环境变量
打开 终端 输入以下命令:
vim ~/.bash_profile
打开.bash_profile文件,在次文件中添加设置环境变量的命令
export M2_HOME=~/Documents/MineCode/Java/Maven-3.6.0
export PATH=$PATH:$M2_HOME/bin
添加之后保存并推出,执行以下命令使配置生效:
source ~/.bash_profile
3、验证
终端输入
mvn -v
配置生效会显示下面的信息
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: /Users/liyn/Documents/MineCode/Java/Maven-3.6.0
Java version: 11.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
Default locale: zh_CN_#Hans, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.2", arch: "x86_64", family: "mac"
相关链接
-
简书:https://www.jianshu.com/p/89b3a420468f
-
CSDN:https://blog.csdn.net/ZuoWeiXiaoDuZuoZuo/article/details/86066414
-
ilongge.cn:http://ilongge.cn/2019/01/08/Mac_OS_X_Maven/