maven项目build时出现 No compiler is provided in this environment.错误

简介: maven项目build时出现 No compiler is provided in this environment.错误

今天创建maven项目build时出现”[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?“我很郁闷,以前创建普通项目时没有遇到这个问题啊,为什么创建maven项目时却会创想JDK的问题呢?


错误信息如下:



[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< Promaven:Promaven >--------------------------
[INFO] Building Promaven 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Promaven ---
[INFO] Deleting D:\javacode\eclipseworkspaces\Promaven\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Promaven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Promaven ---
[WARNING] The POM for org.apache.maven:maven-plugin-api:jar:2.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven:maven-core:jar:2.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\javacode\eclipseworkspaces\Promaven\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.761 s
[INFO] Finished at: 2020-03-05T20:23:07+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Promaven: 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.
[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


其中我们不难发现有这样的信息:


[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?


中文的意思是:


此环境中不提供编译器。也许您运行的是JRE而不是JDK?


打开conf文件下的配置文件setting.xml文件我们会发现这样的一段说明:


<!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>


在上面信息的倒数第二行发现:这个概要文件示例使用JDK版本触发激活,并提供一个特定于JDK的repo

也就是说我们需要指定一个符合配置的JDK环境


依次如下做:

1,Window–>preferences–>Java–>Installed JREs–>installed JREs -->add -->standard VM --next.


20200305212509963.png


2,之后进入JRE Definition界面,点击Directory…选择安装的JDK目录后面的的会自动添加,点击finish就可以了


20200305212938600.png


注意因为我的已经配置了所以显示:the JRE is already in use.


3,选择jdk

20200305214430629.png


4,右击项目–>Build Path–>configure Build Path…


2020030521510197.png


5,选择Java build Path -->双击JRE System…–>选择你JDK相对应的版本。


20200305215351150.png


6,至此该问题就解决了。

相关文章
|
6天前
|
Java 关系型数据库 MySQL
Maven——创建 Spring Boot项目
Maven 是一个项目管理工具,通过配置 `pom.xml` 文件自动获取所需的 jar 包,简化了项目的构建和管理过程。其核心功能包括项目构建和依赖管理,支持创建、编译、测试、打包和发布项目。Maven 仓库分为本地仓库和远程仓库,远程仓库包括中央仓库、私服和其他公共库。此外,文档还介绍了如何创建第一个 SpringBoot 项目并实现简单的 HTTP 请求响应。
31 1
Maven——创建 Spring Boot项目
|
9天前
|
Java 关系型数据库 MySQL
如何使用 maven 创建一个 Spring Boot项目
Maven 是一个强大的项目管理工具,通过配置 `pom.xml` 文件自动获取所需的 jar 包,提高开发效率。其核心功能包括项目构建和依赖管理。项目构建支持编译、测试、打包和发布等流程,而依赖管理则通过中央仓库、本地仓库和私有服务器获取和管理项目依赖。示例中展示了如何创建第一个 SpringBoot 项目并实现简单接口。
13 1
如何使用 maven 创建一个 Spring Boot项目
|
16天前
|
Java Maven Kotlin
idea maven创建kotlin项目
本文介绍了在IntelliJ IDEA中使用Maven创建Kotlin项目的步骤,包括在`pom.xml`文件中添加Maven中央仓库、配置`kotlin-maven-plugin`插件、指定源目录、添加测试插件和执行插件,以及添加Kotlin测试依赖和标准库依赖。文中还提到了如何通过更换镜像或使用代理来解决依赖下载速度慢的问题,并展示了运行示例代码的截图。
44 4
idea maven创建kotlin项目
|
15天前
|
Java Maven Android开发
eclipse创建maven项目
本文介绍了在Eclipse中创建Maven项目的步骤,包括打开Eclipse、选择Java项目、完成项目创建以及自动下载插件的过程。
48 2
eclipse创建maven项目
|
12天前
|
Java 应用服务中间件 Maven
【终极解决方案】IDEA maven 项目修改代码不生效。
【终极解决方案】IDEA maven 项目修改代码不生效。
65 1
|
16天前
|
Java 应用服务中间件 Maven
idea+maven+tomcat+spring 创建一个jsp项目
这篇文章介绍了如何在IntelliJ IDEA中使用Maven和Tomcat创建一个JSP项目,包括配置Maven依赖、设置Tomcat服务器、编写JSP页面、创建控制器和配置文件,以及项目的运行结果。
65 0
idea+maven+tomcat+spring 创建一个jsp项目
|
17天前
|
Java Maven
使用javadoc生成maven项目的文档
本文介绍了如何在Maven项目中使用maven-javadoc-plugin插件来生成项目的JavaDoc文档,并展示了配置插件、编写代码、运行Maven命令以及查看生成文档的完整步骤。
14 0
使用javadoc生成maven项目的文档
|
17天前
|
Java Maven
用graalvm将maven项目打包成可执行文件
本文介绍了如何使用GraalVM将Maven项目打包成可执行文件,包括引入依赖和插件、编写代码、执行打包命令以及运行查看结果的完整过程。
61 0
用graalvm将maven项目打包成可执行文件
|
24天前
|
Java Maven
Maven 项目测试
接下来我们要学习如何构建和测试这个项目。
36 5
|
10天前
|
Java 应用服务中间件 Maven
SpringBoot Maven 项目打包的艺术--主清单属性缺失与NoClassDefFoundError的优雅解决方案
SpringBoot Maven 项目打包的艺术--主清单属性缺失与NoClassDefFoundError的优雅解决方案
122 0