[Solved] Mac Maven Command Error: zsh: command not found

The MVN command cannot be found under Zsh
If Maven is configured, you must execute source ~ /.Bash every time the terminal executes the MVN command_ Profile to take effect. This is because when Zsh is installed on the Mac,. The configuration of the Bash_profile file cannot take effect. The solution is:

vi ~/.zshrc

Add the following command at the end of the file:

source ~/.bash_profile
esc  :wq

Update document:

source ~/.zshrc

In this way, when Zsh starts, it will read. Bash_ The contents of the profile file and make it effective
configure Maven environment variables under Zsh
there are three places on the MAC where you can set environment variables:

/Etc/Profile: system global variable, which loads the configuration of the file upon system startup (not recommended)
/etc/bashrc: all types of bash shells will read the configuration of the file
~ /.Bash_Profile: configure user level environment variables and create them in the system user folder. When a user logs in, the file will be executed only once

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
export PATH=${PATH}:/usr/local/mysql/bin

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$PATH:/usr/local/maven/apache-maven-3.5.0/bin

export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-7.0.77

alias ll='ls -alF'
alias la='ls -A' 
alias l='ls -CF'

Then experiment

mvn -v 
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /Users/yaoyonghao/Documents/software/apache-maven-3.8.4
Java version: 1.8.0_212, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

Read More: