Maven项目打jar包报错:Perhaps you are running on a JRE rather than a JDK?

Maven项目在打jar包时,报错提示:[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

报错的提示已经讲得很清楚,当前运行的环境为JRE,而不是JDK,没有提供编译环境。所以解决的问题关键是将当前项目的运行环境由JRE切换为JDK即可。

默认使用JRE的根源是因为在settings.xml文件中做了如下配置:

Maven项目打jar包报错:Perhaps you are running on a JRE rather than a JDK?_第1张图片

所以在项目中默认使用的JRE如下:

Maven项目打jar包报错:Perhaps you are running on a JRE rather than a JDK?_第2张图片

解决步骤如下图所示,将JRE切换为系统中自己安装的JDK,重新打jar即可。

Maven项目打jar包报错:Perhaps you are running on a JRE rather than a JDK?_第3张图片

Maven项目打jar包报错:Perhaps you are running on a JRE rather than a JDK?_第4张图片

Maven项目打jar包报错:Perhaps you are running on a JRE rather than a JDK?_第5张图片

 

你可能感兴趣的:(Maven)