1. 程式人生 > >IDEA中編譯maven打包中出現 Perhaps you are running on a JRE rather than a JDK的問題解決

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