此环境中没有编译器。也许你正在运行JRE而不是jdk?
时间:2020-02-23 14:34:36 来源:igfitidea点击:
如果我们在运行Maven Build时获得以下错误。
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
有3种方法可以解决 No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?。
eclipse maven错误
如果我们收到此错误,请在执行Maven Beight上 eclipse然后我们必须检查我们是否使用使用 JDK相当 JRE在eclipse。
- 在Eclipse中,单击
Window -> Prefererences -> Java -> Installed JREs - 验证
JDK检查而不是JRE。 - 如果
JRE被选中,然后我们需要通过单击添加 - >标准VM - > Next - >目录并浏览JDK路径来添加JDK
这将解决Eclipse中的错误。
在pom.xml中添加可执行文件
你可以设置 fork真实并忽略完全合格的jdk路径 maven-compiler-plugin。
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.8.0_45\bin\javac.exe</executable>
</configuration>
</plugin>
</plugins>
</build>
将java_home设置为JDK
去 System properties -> Advanced system settings -> Advanced -> environment variable 并添加 JAVA_HOME到环境变量。

