mac mvn 报错:No compiler is provided in this environment. Perhaps you are running on a JRE

1、问题描述:

mac 系统下 idea Terminal 执行 mvn打包报错:

No compiler is provided in this environment. Perhaps you are running on a JRE。

前提:mac 系统已经配置了环境变量。

java -version 可以正常显示
mvn -v 可以正常显示

注:都已配置的情况下提示:

No compiler is provided in this environment. Perhaps you are running on a JRE。

2、排查:

mvn -v 查看 runtime 环境

> mvn -v
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3
Java version: 1.8.0_361, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "12.1", arch: "x86_64", family: "mac"

执行:

/usr/libexec/java_home -V

> /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.361.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_321 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

3、解决办法:

删除掉 JavaAppletPlugin.plugin 这个插件即可。

进入 /Library/Internet Plug-Ins/ 目录,删除 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin

> rm -rf JavaAppletPlugin.plugin

重新执行 mvn -v runtime 正确

> mvn -v
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3
Java version: 1.8.0_321, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "12.1", arch: "x86_64", family: "mac"

你可能感兴趣的:(macos,java,intellij-idea)