D:\>cd D:\004 newCoinInfo 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
时间: 2023-07-24 12:14:57 浏览: 204
根据你提供的信息,出现了一个编译错误:`No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?`。这个错误通常是由于使用 JRE(Java Runtime Environment)而不是 JDK(Java Development Kit)导致的。
JRE 只包含 Java 运行时环境,而 JDK 包含了 JRE 和开发所需的工具(如编译器)。因此,在使用 Maven 进行编译时,需要确保你使用的是 JDK 而不是 JRE。
请按照以下步骤检查和设置 JDK:
1. 首先,确认已经正确安装了 JDK。你可以在命令提示符中使用 `java -version` 命令来验证是否安装了 JDK。如果显示的信息中包含 JDK 的版本号,则表示已安装 JDK;如果显示的信息中只有 JRE 的版本号,则表示只安装了 JRE,需要安装 JDK。
2. 如果尚未安装 JDK,请下载并安装最新版本的 JDK。你可以从官方网站(例如 Oracle 或 OpenJDK)下载适合你操作系统的 JDK 安装程序,并按照安装向导进行安装。
3. 安装完成后,确保设置了正确的 `JAVA_HOME` 环境变量。你可以按照之前提到的方法设置 `JAVA_HOME`,将其指向 JDK 的安装目录。
4. 确保在命令提示符中使用 `java -version` 命令时,显示的是 JDK 的版本号。
完成上述步骤后,重新运行 `mvn clean package` 命令,应该能够成功编译项目。如果问题仍然存在,请确保 Maven 配置中的 JDK 路径正确,并且 Maven 正确地使用了 JDK 来进行编译。
阅读全文