maven clean package 失败 "No compiler is provided in this environment. Perhaps you are running on a "

maven clean package 失败出现异常:

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile 		(default-compile) on project spring-batch-quartz: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[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

尝试解决方案:

先:window–>preference–>java–>installed JREs中添加为jdk,移除原的jre,但是不行

maven clean package 失败
出现新的异常:

The specified JRE installation does not exist

maven clean package 失败

再看,是installed JREs要到 /jdk7/jre目录,但是后来验证并不是,到jdk就行了;

最后 看到有文章说 maven和eclipse默认设置java的compile是分开的,所以去maven的 build配置中查看:
maven clean package 失败

看到,选的是Alternate JRE,切换到Workspace default JRE就行了,over

你可能感兴趣的:(java)