环境
mac M1
异常信息
(base) ➜ springbootqrcode mvn -version The JAVA_HOME environment variable is not defined correctly, this environment variable is needed to run this program.
解决方案
操作步骤
- 查询 java 位置:
/usr/libexec/java_home -v
- 将路径写入环境变量:
# Java JAVA_HOME="/Users/shiyuwang/Library/Java/JavaVirtualMachines/corretto-11.0.20.1-1/Contents/Home" export JAVA_HOME CLASS_PATH="$JAVA_HOME/lib" PATH=".$PATH:$JAVA_HOME/bin"
- 执行生效:
source ~/.bash_profile
成功
mvn -version