使用maven插件时报错

 

使用maven插件时总是报错:

 

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project oecp: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] G:\eclipse-jee\eclipse-jee-galileo-SR2-win32\eclipse\jre\..\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

 根据网上搜的内容,我的eclipse是3.5的,在eclipse的window-preferences-java-installed jres里把jdk由1.6改成1.5,不报错了...

 

--------------------------我是分割线 下面是转贴内容-------------------------------------------------------------

 

在eclipse下用maven编译时,可能会失败,爆出以下提示

Please ensure you are using JDK 1.4 or above and not a JRE (the com.sun.tools.javac.Main class is required).

这是因为eclipse默认是使用jre作为运行环境,而maven编译需要jdk作为运行环境

尝试修改eclipse.ini,加入如下语句

-vm
C:\Progra~1\Java\jdk1.6.0_21\bin\javaw.exe

无效

仔细看其爆出的提示,似乎将JAVA_HOME环境变量指向jdk目录即可,但依然不起作用。

 

其实有个简单办法,就是在eclipse里设置一个jdk的运行环境,然后将当前项目的运行环境设为jdk运行环境即可

步骤

window-preferences-java-installed jres

这里默认有个jre6的JRE定义(maybe你是jre5),一个方法是修改这个jre6,将其location指向你的jdk6目录

另一个办法是点击Add按钮,选择Standard VM,jre home选择你的jdk6目录。点击finish,这时发现多了一个JRE,将其勾上,以后新的项目,就默认使用这个JRE了

然后,进入项目的properties页面,选择Java build path,打开libraries标签,remove默认的jre6,add Libraries,选择JRE system library,选择你刚创建的jdk(已被默认选中),finish

现在运行maven 的编译,一切正常。

 

 

内容转自: http://hi.baidu.com/goosebaby/blog/item/d56313ec05cb52c12f2e21ce.html

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值