1. 问题描述

使用idea对Java工程执行mvn compile命令进行编译,出现以下报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5:compile (default-compile) on project test: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

2. 问题分析

从报错信息上看,是由于环境没有提供编译器,可能编译过程运行在JRE上,而不是JDK上。

查看了idea项目配置的Java编译器为JDK8,且配置的Java路径正确。

执行命令mvn -v,查看maven的配置。发现runtime的路径有些奇怪。

Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /usr/local/apache-maven-3.8.3
Java version: 1.8.0_311, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

3. 解决方案

从网上搜索了解决方案,发现这篇文件介绍的比较靠谱。

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

采用了文章中的方法3,重新设置JAVA_HOME路径。

  • 添加Java环境变量
# cat ~/.bash_profile
export M2_HOME=/usr/local/apache-maven-3.8.3
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
export PATH=$PATH:$M2_HOME/bin:$JAVA_HOME/bin
  • 使环境变量生效
source ~/.bash_profile
  • 查看maven配置
# mvn -v
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /usr/local/apache-maven-3.8.3
Java version: 1.8.0_311, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

发现maven的runtime运行环境已经正常。

此时再次执行编译命令mvn compile,发现Java工程可以正常编译,不在出现报错。

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK 问题解决的更多相关文章

  1. No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK问题解决

    Maven构建项目报错: 解决办法: 1.eclipse菜单 -  Window - Preferences- Java - Installed JREs 将配置的JRE定位到JDK,例如JRE ho ...

  2. 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 ...

  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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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? 你应该 ...

  8. 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 ...

  9. 【maven】maven的web项目打包报错: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 ...

随机推荐

  1. SYCOJ27猴子选大王

    题目-猴子选大王 (shiyancang.cn) 一.出队顺序Description有M个人,其编号分别为1-M.这M个人按顺序排成一个圈.现在给定一个数N,从第一个人开始依次报数,数到N的人出列,然 ...

  2. 【分布式技术专题】「Zookeeper中间件」给大家学习一下Zookeeper的”开发伴侣”—Curator-Framework(基础篇)

    CuratorFramework基本介绍 CuratorFramework是Netflix公司开源的一套Zookeeper客户端框架,它作为一款优秀的ZooKeeper客户端开源工具,主要提供了对客户 ...

  3. 【Java常用类】Instant:瞬时

    Instant:瞬时 时间线上的一个瞬时点. 这可能被用来记录应用程序中的事件时间戳,该类型是面向机器的. now():获取本初子午线对应的标准时间 Instant instant = Instant ...

  4. Docker入门篇(一)安装docker

    Docker入门篇(一)安装docker Docker的来源 由dotCloud公司首创及正式命名,但是企业规模小,影响力不够,所以在快要坚持不住的时候,开始吃百家饭--开源了.不开则已,一开惊人.越 ...

  5. #pragma pack() -----设置默认对齐数

    #pragma pack()  -----设置默认对齐数 预处理命令#pragma:程序如下 则根据修改的对齐数来算:则需要占据内存的大小是14 如果不进行设置,则按照编译器默认的对齐数来算:则需要占 ...

  6. 【笔记】对golang的大量小对象的管理真的是无语了……

    业务中有这样一个struct: type bizData struct{ A uint64 B uint64 C int32 D uint32 } 虽然没有实测,但我猜测这样的对齐方式,这个struc ...

  7. 常用字符的ASCII码

    字母    ASCII码      十进制数 0         00110000      48 9           00111001        57 A          01000001 ...

  8. Git使用简单教程,从建库到远程操作

    本地库初始化 找到项目文件->右键git bash->git init 设置签名 形式: 用户名 邮箱地址 作用: 区分不同开发人员身份 注意:这里设置的签名和登录的远程库的账号密码没有任 ...

  9. gin中的多模板和模板继承的用法

    1. 简单用法 package main import ( "github.com/gin-contrib/multitemplate" "github.com/gin- ...

  10. jsp加载css失效的解决方法

    问题: 有时候大家修改了css文件里的样式,但是刷新浏览器,利用工具看样式的时候,发现样式根本没加载或者说没更新, 其实这出现的问题就是缓存的问题 解决: 如何避免发生这种事,其实很简单,只需要每次请 ...