`

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:com

 
阅读更多

 not a JRE
问题
在使用pom.xml配置默认Goal的时,如果默认的Goal为clean就没问题,但如果是如:

  1. <build>
  2. <defaultGoal>clean compile</defaultGoal>
  3. </build>

就会报错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project Demo: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\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.

  1. 经过几番尝试,才发现并不是多个Goal的问题,而是compile Goal的问题。但使用命令的"mvn compile"又是OK的。
    几经折腾才发现错误里说的很清楚:Please ensure you are using JDK 1.4 or above and not a JRE",它需要的是JDK而不是JRE。我给的项目中使用的是公共JRE:

    解决
    修改Eclipse的配置,使用JDK:Eclipse->Window->Preferences->Java->Installed JREs

    Finish后,项目如:

OK,知之为知之,不知创造条件必须知!!

 

出现问题2:

1、使用spring 注解,如果有两个类的对象一样的名称,程序报错

eg:就会报错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project Demo: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\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.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics