macOS下安装Maven环境

先安装jdk 参考(https://www.lvtao.net/config/1343.html),再来安装maven
下载 Maven (https://maven.apache.org/download.cgi), 并解压到某个目录。例如/usr/local/etc/maven-3.3.9

打开Terminal,输入以下命令,设置Maven classpath

$ vi ~/.bash_profile

添加下列两行代码,之后保存并退出Vi:

export M2_HOME=/usr/local/etc/maven-3.3.9
export PATH=$PATH:$M2_HOME/bin

输入命令以使bash_profile生效

$ source ~/.bash_profile

输入mvn -v查看Maven是否安装成功

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/etc/maven-3.3.9
Java version: 1.8.0_101, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.4", arch: "x86_64", family: "mac"
最后修改时间为:2017 年 04 月 04 日 11 时 46 分 AM
如果觉得我的文章对你有用,请随意赞赏

发表评论