终端输入mvn -version报错:
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.
Java环境变量的问题,打开bash_profile查看
open ~/.bash_profile
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_361.jdk/Contents/Home
alias jdk8='export JAVA_HOME=$JAVA_8_HOME'
#java17
export JAVA_17_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
alias jdk17='export JAVA_HOME=$JAVA_17_HOME'JAVA_HOME=$JAVA_8_HOMEexport PATH=$PATH:/usr/local/mysql/bin
export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"# export PATH=${PATH}:/Users/gorwaywong/Library/Python/3.9/bin
export PATH="/Users/gorwaywong/anaconda3/bin:$PATH"# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/gorwaywong/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; theneval "$__conda_setup"
elseif [ -f "/Users/gorwaywong/anaconda3/etc/profile.d/conda.sh" ]; then. "/Users/gorwaywong/anaconda3/etc/profile.d/conda.sh"elseexport PATH="/Users/gorwaywong/anaconda3/bin:$PATH"fi
fi
unset __conda_setup
# <<< conda initialize <<<export PATH="/opt/homebrew/bin:$PATH"
发现Java8和Java17版本的环境变量都有,而且默认是Java8
终端中输入:
jdk17
查看版本成功.