0

这是java home和路径配置。不知道为什么 maven 没有正确检测到 java home。在 MacBook 上通过 sdkman 安装了 java 11 和 maven。谢谢。

m-c02yw:~ vn$ echo $JAVA_HOME

/Users/vn/.sdkman/candidates/java/current


m-c02yw:~ vn$ echo $PATH


/Users/vn/.sdkman/candidates/maven/current/bin:/Users/vn/.sdkman/candidates/java/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/munki


m-c02yw:~ vn$ java -version
openjdk version "11.0.14" 2022-01-18 LTS
OpenJDK Runtime Environment Zulu11.54+23-CA (build 11.0.14+9-LTS)
OpenJDK 64-Bit Server VM Zulu11.54+23-CA (build 11.0.14+9-LTS, mixed mode)


m-c02yw:~ vn$ $JAVA_HOME/bin/javac -version
javac 11.0.14


m-c02yw:~ vn$ mvn -version
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
4

1 回答 1

0

mvn 正在从 ~/.mavenrc 加载它的 java_home

cat $HOME/.mavenrc JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

在这里改变了它,我的问题得到了解决。

于 2022-02-17T21:39:33.393 回答