Maven错误:[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?的解决方法

错误:

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

解决方法:

1、如果是Eclipse时,应该是安装好JDK后Eclipse默认使用的是JRE,所以只要调节回来即可。

两种方式都可行:

②、

2、如果一个Maven项目导入Eclipse之后,而上面又没有设置成JDK的路径时,此时也会出现如上错误,那么解决方法就是把Eclipse自动生成的文件全部删除,只保留远程Maven的目录结构。

3、还可以直接针对插件制定版本,比如在POM上增加如下插件的配置:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <fork>true</fork>
        <executable>D:Javajdk1.7.0_17injavac.exe</executable>
    </configuration>
</plugin>

不过不建议使用这种方法,版本和路径不容易在每台机器上控制。

参考:

https://stackoverflow.com/questions/19655184/no-compiler-is-provided-in-this-environment-perhaps-you-are-running-on-a-jre-ra

http://blog.csdn.net/fox_lht/article/details/16369147

原文地址:https://www.cnblogs.com/EasonJim/p/7358459.html