Perhaps you are running on a JRE rather than a JDK?
意思是此环境中未提供编译器,你可能使用jre运行而不是jdk。
java -version
查看了下环境,发现不是原来的环境了,
去官网下载jdk后,配置环境变量后问题解决。
查看jdk位置
打开终端窗口,执行命令:/usr/libexec/java_home -V
Matching Java Virtual Machines (4):
1.8.271.09 (x86_64) “Oracle Corporation” – “Java” /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_271 (x86_64) “Oracle Corporation” – “Java SE 8″ /Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
1.8.0_171 (x86_64) “Oracle Corporation” – “Java SE 8” /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
1.7.0_80 (x86_64) “Oracle Corporation” – “Java SE 7” /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
这边显示有多个环境,这边选刚安装的最新的加入到环境变量
(可以加入到多个地方 ~/.bash_profile
或者 /etc/profile
)
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH
然后让变量生效
source /etc/profile
(若是加在.bash_profile
则 source ~/.bash_profile
)
再验证
java -version
最后mvn成功打包。