在用eclipse搭建maven项目时,运行run as -> maven build等指令时,会出现如下错误:
Build errors for spider; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project spider: Compilation failure
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.
解决方法如下:
1、配置 eclipse.ini
在-startup前加多一行:-vm C:\Program Files\Java\jdk1.6.0_21\jre\bin\javaw.exe
2、点击 windows -> preferences -> java -> Installed JREs。
编辑jre,在jre里,加入java/jdk/jre/lib里的jar包,其实就是提示缺少什么jar包,就在里面添加进去就行了。