IDEA中编译maven打包中出现 Perhaps you are running on a JRE rather than a JDK的问题解决

LZ是在IDEA新建的maven项目,到DOS界面打包时,提示:

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

这个报错的意思是maven需要JDK环境而不是JRE环境。

网上搜了一堆都是修改eclipse的环境配置,而我用的是IDEA,不太适用,其实究其原因是JDK的环境变量配置有误

LZ当时配置时,为了图省事,没有配置以JAVA_HOME命名的环境变量,建议大家遇到这个问题老老实实按照网上教程重新配置下JDK的环境变量即可。前期麻烦后期就省事了。

环境变量的配置可以按照这个来,我JDK版本是JDK.10.0.1
JDK环境变量配置

重新配完,再在maven项目所在路径下执行mvn clean package -DskipTests
显示成功

[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ hadoop-train ---
[INFO] Deleting E:\JavaWork\IDEA\hadooptrain\target
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ hadoop-train ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\JavaWork\IDEA\hadooptrain\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ hadoop-train ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\JavaWork\IDEA\hadooptrain\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ hadoop-train ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\JavaWork\IDEA\hadooptrain\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ hadoop-train ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\JavaWork\IDEA\hadooptrain\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ hadoop-train ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ hadoop-train ---
[INFO] Building jar: E:\JavaWork\IDEA\hadooptrain\target\hadoop-train-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.863 s
[INFO] Finished at: 2018-05-01T16:35:16+08:00

你可能感兴趣的:(学习实践与记录)