mvn clean package 错误:不兼容的类型的解决方案

D:\004 newCoinInfo>java -version java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode) D:\004 newCoinInfo>echo %JAVA_HOME% D:\JDK 但是 D:\004 newCoinInfo>mvn clean package [INFO] Scanning for projects... [INFO] [INFO] ------------------------< com.example:test_reg >------------------------ [INFO] Building test_reg 0.0.1-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- clean:3.2.0:clean (default-clean) @ test_reg --- [INFO] Deleting D:\004 newCoinInfo\target [INFO] [INFO] --- resources:3.2.0:resources (default-resources) @ test_reg --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to copy filtered properties files. [INFO] Copying 1 resource [INFO] Copying 1 resource [INFO] [INFO] --- compiler:3.10.1:compile (default-compile) @ test_reg --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 7 source files to D:\004 newCoinInfo\target\classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.914 s [INFO] Finished at: 2023-07-19T18:31:17+08:00 [INFO] ------------------------------------------------------------------------ [WARNING] [WARNING] Plugin validation issues were detected in 2 plugin(s) [WARNING] [WARNING] * org.apache.maven.plugins:maven-resources-plugin:3.2.0 [WARNING] * org.apache.maven.plugins:maven-compiler-plugin:3.10.1 [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 test_reg: Compilation failure [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [ERROR] [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. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 报错
07-20
根据你提供的信息,`JAVA_HOME` 已经设置为 `D:\JDK`,并且 `java -version` 命令显示的也是 JDK 版本。 然而,在运行 `mvn clean package` 命令时,仍然出现了错误:`No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?`。 这可能是因为在你的系统中,Maven 无法正确找到 JDK 的编译器。为了解决这个问题,你可以尝试以下几个解决方案: 1. 确保你安装的 JDK 版本与 Maven 兼容。有时候,可能会出现 Maven 与某些 JDK 版本不兼容的情况。你可以尝试安装不同版本的 JDK,并确保使用与 Maven 兼容的版本。 2. 检查你的系统环境变量。在环境变量中,确保 `JAVA_HOME` 指向的是 JDK 的安装目录,并且将 `%JAVA_HOME%\bin` 添加到系统的 `PATH` 环境变量中。 3. 确认 Maven 配置文件是否正确设置了 JDK 的路径。在 Maven 的配置文件 `settings.xml` 中,查找 `<jdkHome>` 元素,并确保其值与 JDK 的安装路径一致。 4. 尝试重新安装 Maven。有时候,Maven 可能会出现一些配置问题,重新安装可能会解决这些问题。 如果上述解决方案都不起作用,你可以尝试在命令行中直接指定 JDK 的路径来运行 Maven 命令。例如: ``` "D:\JDK\bin\mvn" clean package ``` 这将直接使用指定路径下的 JDK 来执行 Maven 命令。 希望以上解决方案能够帮助你解决问题。如果问题仍然存在,请提供更多的错误信息或日志,以便更进一步的排查。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值