构建项目时Maven包(构建错误)

时间:2011-02-25 05:38:48

标签: maven

我正在使用Springs进行开发。我正在使用eclipse.Earlier我的项目已经成功构建但是当我在我的应用程序中粘贴了一些更多的文件时,当我说Run作为“Maven Package”时,我遇到了错误。我不明白为什么这个错误会在某些时间之间发生。

当我说Run as Maven package

时出现以下错误
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building HeyLets 0.8-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ HeyLets ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ HeyLets ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\temp\temp_wsp\HeyLetsNew\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre6\..\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.156s
[INFO] Finished at: Fri Feb 25 11:04:37 IST 2011
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project HeyLets: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre6\..\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

3 个答案:

答案 0 :(得分:1)

我按照Raghuram指向的线程中的说明修复了问题。 您必须将使用过的JRE更改为JDK中的JRE。

转到首选项/ Java /已安装的JRE并为位置添加一个" C:\Program Files\Java\jdk1.6.0_27\jre"或类似的东西。 删除" C:\Program Files\Java\jre6"。

再次运行你的maven脚本,如你所见,问题解决了!

答案 1 :(得分:1)

  

[错误]无法找到Javac编译器:   C:\ PROGRAMFILES \爪哇\ JRE6 .. \ lib中\的tools.jar

使用jdk jre: C:\ Program Files \ Java \ jdk1.6.0_27 \ jre($ BaseDir)

现在路径jre \ .. \ lib \ tools.jar是对的。 (..表示父目录)

$ BaseDir \ jre \ .. \ lib \ tools.jar等于$ BaseDir \ lib \ tools.jar

在Eclipse中转到Windows - >偏好 - > Java - >已安装的JRE

并添加或更改位置 “C:\ Program Files \ Java \ jdk1.6.0_27 \ jre”或类似内容。

答案 2 :(得分:0)

也许您正面临this线程中讨论的相同问题。如果是这样,也会在线程中提出解决方法。