当前位置: 首页 > 知识库问答 >
问题:

Mac os Big Sur在此环境中没有提供编译器。也许您运行的是JRE而不是JDK?

钮轩昂
2023-03-14

共有1个答案

辛可人
2023-03-14

我遇到了和你一样的问题。
这个解决方案(构建失败运行“mvn clean install”。我刚刚升级了Big Sur)是删除无用的JRE。
我的是给mvn shell一个正确的java_home。

当我运行命令/usr/libexec/java_home-v

我可以看到2个虚拟机

MacBook-Pro:bin charles$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.251.08 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_251 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
    #
    # Apple JDKs
    #
    export JAVA_HOME=`/usr/libexec/java_home`
fi
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
    #
    # Apple JDKs
    #
    export JAVA_HOME=`/usr/libexec/java_home -v1.8.0`
fi

然后,它起作用了。

MVN-version

在我更新mvn之前,我将看到

MacBook-Pro:~ charles$ mvn -version
Apache Maven ........
Maven home: ........
Java version: 1.8.0_251, vendor: Oracle Corporation
Java home: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_TW, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
MacBook-Pro:~ charles$ mvn -version
Apache Maven ........
Maven home: .......
Java version: 1.8.0_251, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/jre
Default locale: zh_TW, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
 类似资料: