为什么 jdk 运行良好但得到 mvn 编译错误

时间:2021-07-23 15:19:41

标签: java maven

我的 jdk 运行良好,但运行 mvn compile 时出现错误

PS H:\Learning\Maven> java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
PS H:\Learning\Maven> mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.xxx:maven01 >---------------------------
[INFO] Building maven01 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven01 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven01 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to H:\Learning\Maven\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.566 s
[INFO] Finished at: 2021-07-23T23:18:05+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven01: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

1 个答案:

答案 0 :(得分:1)

javac 运行良好。在我将 JAVA_HOME 的 jre 更改为 jdk 后,我没有重新打开 powershell,它一直给我错误。