MAC添加MVN、JAVA等环境变量
2021-11-03 本文已影响0人
雄创_Jasic
机器:2019款mac,系统10.15.7 (19H2)
由于机器是新购,没有任何环境,需要在shell中使用mvn命令,非MAC自带terminate,使用的是iTerm2终端;
首先想到不在/etc/profile变更系统件,只会在当前用户下处理
1、view ~/.bash_profile
2、view ~/.zprofile
3、在~/.zprofile 中添加命令source ~/.bash_profile
4、保存退出,生效
image.png
原理:在mac中默认使用zsh作为shell执行器,而 直接在某个session中source ~/.bash_profile不会在其它会话中生效,需要在每次启用新会话时执行一下source /.bash_profile,而/.zprofile 是zsh会默认执行的一个配置文件,或者可直接将/.bash_profile的内容放/.zprofile 即可。