Java Maven -错误:未提供编译器

6rqinv9w  于 2023-11-15  发布在  Java
关注(0)|答案(2)|浏览(183)

我尝试使用IntelliJ和Maven,但我有一个问题。我有JDK:corretto-11.0.21。

mvn -version
Apache Maven 3.9.2 (c9616018c7a021c1c39be70fb2843d6f5f9b8a1c)
Maven home: C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.2.3\plugins\maven\lib\maven3
Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jre1.8.0_211
Default locale: pl_PL, platform encoding: Cp1250
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

字符串
当我使用命令:mvn clean package时

[WARNING] Plugin validation issues were detected in 2 plugin(s)
[WARNING]
[WARNING]  * org.apache.maven.plugins:maven-compiler-plugin:3.10.1
[WARNING]  * org.apache.maven.plugins:maven-resources-plugin:3.3.0
[WARNING]
[WARNING] For more or less details, use 'maven.plugin.validation' property with one of the values (case insensitive): [BRIEF, DEFAULT, VERBOSE]
[WARNING]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project MavenTest3: Compilation failure        
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.


我是Java新手。我一直在尝试解决这个问题,但无济于事。提前感谢您的帮助。

bt1cpqcv

bt1cpqcv1#

您正在使用JRE而不是JDK。将环境变量JAVA_HOME设置为实际JDK的路径。JRE不包括编译器。

ercv8c1e

ercv8c1e2#

你已经把所有的东西都贴出来了:
正如Maven在错误输出中所述:

Perhaps you are running on a JRE rather than a JDK?

字符串
加上上面的输出还显示

Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jre1.8.0_211`.


因此,在再次调用Maven之前,只需安装适当的JDK并正确设置JAVA_HOME。

相关问题