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
如果你打开后已经选中了jdk则不需要处理,如果是jre的话,就点击add
点击next,选择你的jdk的位置,最后finish
最后选中jdk,下面的jre也可以删掉
我们看看Maven的环境是如何配置的:先找到Eclipse-->Window-->preferences-->Maven-->Installations
在Maven配置中, 我并没有使用Eclipse自带的Maven插件, 而是重新配置的Maven环境, 然后再看Eclipse-->Window-->preferences-->Maven-->User Settings
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项目用eclipse打包发布的问题(No compiler is provided in this environment!)
-
maven项目build时出现 No compiler is provided in this environment.错误
-
Maven构建项目出现No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
-
Maven构建项目出现No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?