Java 控制台 maven 编译错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19827165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 20:32:01  来源:igfitidea点击:

Console maven compile error

javaspringmaven

提问by Sam Derin

i was macking one of the oficial guides of spring: http://spring.io/guides/gs/maven/

我正在阅读春季的官方指南之一:http://spring.io/guides/gs/maven/

But when y reach the part where i have to compile with maven this is what happens:

但是当你到达我必须用 maven 编译的部分时,就会发生这种情况:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-maven-initial 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ gs-maven-i
nitial ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory c:\Java\WorkSpace\maven_beginer\src\m
ain\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ gs-maven-init
ial ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 2 source files to c:\Java\WorkSpace\maven_beginer\target\classe
s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.692s
[INFO] Finished at: Wed Nov 06 23:51:21 ART 2013
[INFO] Final Memory: 9M/102M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
5.1:compile (default-compile) on project gs-maven-initial: Fatal error compiling
: tools.jar not found: C:\Java\jdk\..\lib\tools.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

采纳答案by Sasikumar Murugesan

You can resolve this issue by

您可以通过以下方式解决此问题

  1. Add JAVA_HOME to System variable
  2. or Copy you java folder to c:\ from c:\program files or c:\program files (x86)
  3. or Missing tools.jar in local repository breaks m2eclipse
  1. 将 JAVA_HOME 添加到系统变量
  2. 或将您的 java 文件夹从 c:\program files 或 c:\program files (x86) 复制到 c:\
  3. 在本地存储库中缺少 tools.jar 会破坏 m2eclipse

回答by searching9x

Goto Windows -> Preferences Java -> Installed JREs

转到 Windows -> Preferences Java -> Installed JREs

v

v

Change JRE to JDK

将 JRE 更改为 JDK