使用intellij idea项目maven编译时发现报错误:

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

先说下我的机器上的环境:

Intellij idea Perhaps you are running on a JRE rather than a JDK_maven

项目使用的是jdk1.8.0_152

Intellij idea Perhaps you are running on a JRE rather than a JDK_ide_02

我windows的默认环境jdk是

Intellij idea Perhaps you are running on a JRE rather than a JDK_ide_03

我的maven环境的依赖是

Intellij idea Perhaps you are running on a JRE rather than a JDK_ide_04

 

所以我执行mvn package的时候maven还是引用的jre 1.8.0_73,jre与jdk的区别大家应该是知道的,jre 是运行时环境,不带开发相关工具包,jdk>jre。

所以把系统JAVA_HOEM环境变量改成jdk即可。

Intellij idea Perhaps you are running on a JRE rather than a JDK_maven_05

 

bingo!