欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Maven项目build时出现No compiler is provided in this environment的解决方法

程序员文章站 2024-02-07 22:23:22
...

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

错误代码节选:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.436 s
[INFO] Finished at: 2017-06-28T11:16:07+08:00
[INFO] Final Memory: 10M/151M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project manage: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]

解决方法:

        看Eclipse-->Window-->preferences-->Java-->Installed JREs

Maven项目build时出现No compiler is provided in this environment的解决方法

如果你打开后已经选中了jdk则不需要处理,如果是jre的话,就点击add

Maven项目build时出现No compiler is provided in this environment的解决方法

点击next,选择你的jdk的位置,最后finish

Maven项目build时出现No compiler is provided in this environment的解决方法

最后选中jdk,下面的jre也可以删掉

Maven项目build时出现No compiler is provided in this environment的解决方法

我们看看Maven的环境是如何配置的:先找到Eclipse-->Window-->preferences-->Maven-->Installations

Maven项目build时出现No compiler is provided in this environment的解决方法

 

在Maven配置中, 我并没有使用Eclipse自带的Maven插件, 而是重新配置的Maven环境, 然后再看Eclipse-->Window-->preferences-->Maven-->User Settings

Maven项目build时出现No compiler is provided in this environment的解决方法

 

Maven设置使用的是Maven中conf文件夹下的settings.xml

在180行左右的profiles标签内加入这么一段话

<profile>
      <id>jdk-1.8</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
</profile>

在项目上右键Build Path,进入

Maven项目build时出现No compiler is provided in this environment的解决方法

Maven项目build时出现No compiler is provided in this environment的解决方法

然后再编译运行项目即可.

相关标签: maven