maven项目打包时,[ERROR] Unable to locate the Javac Compiler in:

错误内容

[ERROR] Unable to locate the Javac Compiler in:
  D:\installed\jre1.8\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.829 s
[INFO] Finished at: 2018-04-04T13:46:27+08:00
[INFO] Final Memory: 9M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project BIService: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] D:\installed\jre1.8\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[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

错误原因

安装jdk时,jdk和jre分成两个目录安装了。并且,在idea里面设置时,jre设置为外面的加热。


Windows ->Preference ->java ->Installed JREs


解决方法 

选择jdk里面的jre


结果

修改后一切正常

猜你喜欢

转载自blog.csdn.net/Poppy_Evan/article/details/79816815
今日推荐