xiayu 发表于 2017-1-14 07:21:18

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

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

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

[*]经过几番尝试,才发现并不是多个Goal的问题,而是compile Goal的问题。但使用命令的"mvn compile"又是OK的。
几经折腾才发现错误里说的很清楚:Please ensure you are using JDK 1.4 or above and not a JRE",它需要的是JDK而不是JRE。我给的项目中使用的是公共JRE:
http://www.oseye.net/upload/attached/image/20140321/20140321163228_48354.gif
解决
修改Eclipse的配置,使用JDK:Eclipse->Window->Preferences->Java->Installed JREs
http://www.oseye.net/upload/attached/image/20140321/20140321163546_71815.gif
Finish后,项目如:
http://www.oseye.net/upload/attached/image/20140321/20140321163626_94930.gif
OK,知之为知之,不知创造条件必须知http://www.oseye.net/assets/common/smileys/gza.gif!!
  出现问题2:
  1、使用spring 注解,如果有两个类的对象一样的名称,程序报错
  eg:就会报错误:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project Demo: Compilation failure
Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre7\..\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]
查看完整版本: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:com