Mac 命令行:zsh:找不到命令:mvn

Mac command line: zsh: command not found: mvn

我在 /Users/chenmin/software/apache-maven-3.6.3 中安装了 maven,当我输入 cat ~/.bash_profile 时,它 returns:

export PATH=$PATH:/Users/chenmin/software/apache-maven-3.6.3/bin
export PATH=${PATH}:/usr/local/mysql/bin
export PATH=${PATH}:/usr/local/mysql/support-files
export PATH=$PATH:/Users/chenmin/software/apache-tomcat-8.5.58/bin
export PATH=$PATH:/Users/chenmin/software/apache-tomcat-8.5.58/logs
export PATH=$PATH:/Users/chenmin/software/redis/6.0.9/bin
export PATH=$PATH:/Users/chenmin/software/rabbitmq
export PATH=$PATH:/usr/local/sbin

/Users/chenmin/software/apache-maven-3.6.3/bin也包含在变量$PATH中。但是,每次我打开一个新命令 window 并键入 mvn 命令(例如 mvn clean install)时,它都会提示 zsh: command not found: mvn,而当我键入 source ~/.bash_profile 时,命令可以正确执行,即使我没有修改文件~/.bash_profile,谁能回答为什么?

如果您现在正在使用 zsh,您可能必须使用 ~/.zshrc 而不是 ~/.bash_profile