一、现象:
运行mvn有关命令,报错“zsh: command not found: mvn”
二、原因
环境变量的配置文件没有生效。
三、解决方法
法一
使配置文件生效,使用如下命令。
source ~/.bash_profile
法二
现象:法一只能解决一次问题,因为重新打开终端,执行mvn相关命令,依然报错“zsh: command not found: mvn”,需要再执行source ~/.bash_profile才可以。
原因:zsh的配置文件没有加载~/.bash_profile的配置项。
解决方法:在zsh的配置文件中添加source ~/.bash_profile配置项的内容
vim ~/.zshrc
添加如下内容:
source ~/.bash_profile