Mac mvn : command not found

时间:2024-03-25 12:06:59

 

去/usr/local目录下面(可以打开Finder command+shift+G),把解压出来的文件拷贝到这个目录下面

Mac mvn : command not found

/usr/local/apache-maven-3.6.3

1、$ sudo vi ~/.bash_profile

添加如下配置:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home

export JAVA_HOME

M2_HOME=/usr/local/apache-maven-3.6.3

export M2_HOME

PATH=${PATH}:${JAVA_HOME}/bin:${M2_HOME}/bin

export PATH

2、配置了Java的环境变量,直接在后面添加M2_HOME变量即可。添加完后退出,并运行source ~/.bash_profile,使配置文件生效,然后运行mvn -v查看:

Mac mvn : command not found

3、执行命令:mvn -v

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

Maven home: /usr/local/apache-maven-3.6.3

Java version: 1.8.0_251, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/jre

Default locale: zh_CN, platform encoding: UTF-8

OS name: "mac os x", version: "10.14.5", arch: "x86_64", family: "mac"