No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK错误

在命令行中执行编译(mvn compile)maven项目时,提示[ERROR] No compiler is providedin this environment. Perhaps you are running on a JRE rather than a JDK?错误信息,具体详细如下

[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.787 s
[INFO] Finished at: 2018-03-11T15:33:10+08:00
[INFO] Final Memory: 8M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project simple: 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

 刚开始搞maven项目,在网上搜索下资料发现都是基于eclipse开发的,而我的是直接使用mvn在命令行执行的,不适合我的情况,但是我想也是jdk的配置问题。后来我又检查了下jdk的配置,发现我只配置了path的内容,没有配置JAVA_HOME,于是我试着配置了,然后重新打开一个命令行窗口重新执行命令,发现问题解决了。原来是没有配置JAVA_HOME的原因,JAVA_HOME对于使用eclipse工具开发可有可无,但是如果使用最基本的命令行操作,它还是需要配置上的。

你可能感兴趣的:(异常处理)