[转]在Eclipse整合Maven3.6.3插件导入maven项目并编译时,控制台提示No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
近日有同事遇到在编译Maven项目时出现
[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]
但是编写普通Java Project编译运行却是正常的,下图为只有输出语句的普通java类
从上图中可以看出, java编译环境未jre1.7.0_17, 也就是说并没有配置成jdk目录, 然后看Eclipse-->Window-->preferences-->Java-->Installed JREs
为了演示出效果, 在测试之前, 我已经将系统java环境配置成如上图所示路径, 并只保留该配置, 由下图可以看出, 该路径是我所安装的两个JDK版本中的一个JDK自带的jre运行环境. 使用该环境编译普通项目没有问题, 但为什么会在编译Maven项目时出错呢?
我们看看Maven的环境是如何配置的:先找到Eclipse-->Window-->preferences-->Maven-->Installations
在Maven配置中, 我并没有使用Eclipse自带的Maven插件, 而是重新配置的Maven环境, 然后再看Eclipse-->Window-->preferences-->Maven-->User Settings
Maven设置使用的是Maven中conf文件夹下的settings.xml, 点击"open file" 在Eclipse中查看具体配置信息, 仅摘录与本错误信息相关的部分
<profiles>
<!-- profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.--> <profile>
<id>jdk-1.7</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
中间具体信息的理解, 可以参见冰河winner的博客:Maven之配置文件. 也就是说, 根据上面的配置, 我们需要指定一个符合配置的JDK环境, 这是我们之前在Eclipse-->Window-->preferences-->Java-->Installed JREs下的配置就不行了, 而需要指定一个JDK目录, 例如我的JDK安装目录下的jdk1.7.0_17, 这也是这个错误出现的罪魁祸首. 不过对于Java开发者来说, Installed JREs中使用jdk目录而不适用jre目录也是最好的选择.
步骤:
————————————————
版权声明:本文为CSDN博主「Code_buger」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:关于Maven项目build时出现No compiler is provided in this environment的处理
[转]在Eclipse整合Maven3.6.3插件导入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 enviroment. Perhaps you are running on a JRE rathen a JDK ?
用maven对项目进行构建时,提示No compiler is provided in this enviroment. Perhaps you are running on a JRE rathen ...
- 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 tha ...
- Maven No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 问题
maven编译项目时出错,提示信息如下: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3 ...
- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
以前用MyEclipse,现在用eclipse配置maven后,运行run install.报错: [ERROR] No compiler is provided in this environmen ...
- maven No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
maven install项目时出错,提示信息如下: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-pl ...
- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 问题
maven编译项目时出错,提示信息如下: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3 ...
- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? idea maven 打包报错问题解决
mvn clean install -X -Dmaven.test.skip=true -P dev 打包报错: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解决(能力工场小马哥)
问题描述: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JD ...
- Maven构建项目出现No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 你应该 ...
- maven install 报错 No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
1.控制台打印信息 [INFO] Scanning for projects... [INFO] [INFO] ---------------------< org.cqupt.mauger:R ...
随机推荐
- 云原生周刊:Kubernetes 1.27 服务器端字段校验和 OpenAPI V3 进阶至 GA
开源项目推荐 KubeView KubeView 是一个 Kubernetes 集群可视化工具和可视化资源管理器.它允许用户在集群内部运行命令,并查看集群内部的资源使用情况.容器运行状态.网络流量等. ...
- 云原生爱好者周刊:买个蓝牙打印机实时打印新提交的 PR 吧 | 2022-10-24
开源项目推荐 blue 这个项目非常有意思,利用树莓派.蓝牙热敏打印机和 GitHub Actions 自动将新提交的 PR 或者 Issue 通过打印机打印出来,非常适合各个项目的维护者使用 Kub ...
- 基于 Python + Vue3!一个轻量级的域名和 SSL 证书监测平台!
大家好,我是 Java陈序员. 在企业开发中,由于业务众多,涉及到很多业务域名证书,证书过期由于遗忘常常未能及时续期,导致线上访问异常,给企业带来损失! 今天,给大家介绍一个轻量级的域名和 SSL 证 ...
- ToDesk云电脑进军游戏市场,真显卡高性能,新版本可暂停使用时长!
ToDesk远程控制软件在装机量突破1.5亿后,再度迎来里程碑式的发展.今年,该公司创新推出了云电脑产品,正式涉足云计算领域.这款前沿产品一经发布,便凭借其卓越的性能和使用体验赢得了广大用户的赞誉.近 ...
- java基础语法(从0开始到java方法)
文章目录 1.第一个java程序 2.数据的表示详解 2.1 整数在计算机中的存储原理 2.2 字符在计算机中的存储原理 2.3 图片视频声音的存储原理 2.4 数据的其他表示形式 2.5 不同进制在 ...
- JS Parser Combinator (解析器组合子)
前言 前些天偶然看到以前写的一份代码,注意有一段尘封的代码,被我遗忘了.这段代码是一个简单的解析器,当时是为了解析日志而做的.最初解析日志时,我只是简单的正则加上分割,写着写着,我想,能不能用一个简单 ...
- postcss-px-to-viewport 移动端适配
以前做移动端项目的时候都是用rem来做适配,现在基本上都是通过viewport单位来做. postcss-px-to-viewport就是一个将px单位转换为视口单位的 (vw, vh, vmin, ...
- vagrant 安装centos8 虚拟机搭建lamp环境
首先保证已经安装了 virtualbox vagrant两个软件 然后找个目录下载centos8 的 box wget https://vagrantcloud.com/generic/boxes/c ...
- rust 终端输出 debug 信息
配置方法 将 env_logger log 添加到 Cargo.toml : 打开 Cargo.toml 文件并在 [dependencies] 部分下添加 env_logger log . [pac ...
- (Redis基础教程之一)如何在Ubuntu 18.04上安装和保护Redis
如何在ubuntu18.04上安装和保护redis 如何连接到Redis数据库 如何管理Redis数据库和Keys 如何在Redis中管理副本和客户端 如何在Redis中管理字符串 如何在Redis中 ...