Mac mvn : command not found

Mac下运行mvn提示命令找不到的原因是Maven的环境变量没有配置解决办法:首先找到Maven安装的目录,比如我这里的Maven安装在了文稿下面木,目录是/Users/kk/Documents/maven/apache-maven-3.39在.bash_profile文件中添加Maven的配置,运行

huyikangdeMacBook-Pro:vbap-webservice kangkang$ sudo vi ~/.bash_profile
添加如下M2_HOME配置:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
export JAVA_HOME

M2_HOME=/Users/kangkang/Documents/maven/apache-maven-3.3.9
export M2_HOME

PATH=${PATH}:${JAVA_HOME}/bin:${M2_HOME}/bin
export PATH
这里我之前配置了Java的环境变量,直接在后面添加M2_HOME变量即可。添加完后退出,并运行source ~/.bash_profile,使配置文件生效,然后运行mvn -v查看:
huyikangdeMacBook-Pro:~ kk$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /Users/kk/Documents/maven/apache-maven-3.3.9
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.1", arch: "x86_64", family: "mac"
成功!

你可能感兴趣的:(Maven/Gradle)