简体   繁体   English

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

[英]Maven package (build error) while building project

I am using Springs for development. 我正在使用Springs进行开发。 And I am using eclipse.Earlier my project was getting built successfully but as I pasted some more files in my application in some packages I am getting following error when I say Run as "Maven Package". 我正在使用eclipse.Earlier我的项目已经成功构建但是当我在我的应用程序中粘贴了一些更多的文件时,当我说Run作为“Maven Package”时,我遇到了错误。 I am not understanding why is this error getting in between some times. 我不明白为什么这个错误会在某些时间之间发生。

I get following error when I say Run as Maven package 当我说Run as Maven包时,我得到以下错误

[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

I fixed the problem by following the instructions in the thread pointed by Raghuram. 我按照Raghuram指出的线程中的说明修复了问题。 You got to change the used JRE to the one inside the JDK. 您必须将使用过的JRE更改为JDK中的JRE。

Go to Preferences/Java/Installed JREs and add one for the location " C:\\Program Files\\Java\\jdk1.6.0_27\\jre " or something like that. 转到首选项/ Java /已安装的JRE,并为位置“ C:\\Program Files\\Java\\jdk1.6.0_27\\jre ”或类似内容添加一个。 Remove the one for " C:\\Program Files\\Java\\jre6 ". 删除“ C:\\Program Files\\Java\\jre6 ”。

Run your maven script again, and as you can see, problem is solved! 再次运行你的maven脚本,如你所见,问题解决了!

[ERROR] Unable to locate the Javac Compiler in: C:\\ProgramFiles\\Java\\jre6..\\lib\\tools.jar [错误]无法找到Javac编译器:C:\\ ProgramFiles \\ Java \\ jre6 .. \\ lib \\ tools.jar

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

Now path jre\\..\\lib\\tools.jar is right. 现在路径jre \\ .. \\ lib \\ tools.jar是对的。 (.. mean parent directory) (..表示父目录)

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

In Eclipse go to Windows -> Preferences - > Java -> Installed JREs 在Eclipse中,转到Windows - > Preferences - > Java - > Installed JREs

and add or change the location to "C:\\Program Files\\Java\\jdk1.6.0_27\\jre" or something like that. 并将位置添加或更改为“C:\\ Program Files \\ Java \\ jdk1.6.0_27 \\ jre”或类似的东西。

Perhaps you are facing the same problem discussed in this thread. 也许您正面临在主题中讨论的相同问题。 If so, a workaround is suggested in the thread as well. 如果是这样,也会在线程中提出解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM