maven项目bulid报No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

 错误信息如下:

[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: 1.103 s
[INFO] Finished at: 2019-08-26T17:41:36+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project springmvc: 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
根据错误信息提示:No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
这个环境中没有提供编译器。也许您运行的是JRE而不是JDK?

1:首先查看 Eclipse-->Window-->preferences-->Java-->Installed JREs
果然java编译环境是jre,而maven项目的运行需要指定一个符合配置的JDK环境,所以我们配置一个jdk目录,并且指定为jdk目录,同时为了防止出错,我把jre目录删除掉了
 



2:项目右键-->build path-->configure build path-->java Build Path-->接着图片操作




3.项目右键-->run as -->run configurations..--> jre -->execution environment选择刚刚配置的jdk-->run


 以上!

猜你喜欢

转载自www.cnblogs.com/sunchunmei/p/11414346.html