錯誤記錄Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-co...

在IDEA Terminal終端運行$ mvn clean package -Dmaven.test.skip=true進行清除編譯文件時報錯。

[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: 2.367 s
[INFO] Finished at: 2020-03-09T11:49:57+08:00
[INFO] Final Memory: 10M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project m
aven_pro1: 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、 檢查pom.xml文件中關于maven編譯插件的版本信息

<plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
           <source>1.7</source>
           <target>1.7</target>
           <encoding>UTF-8</encoding>
           <compilerArguments>
             <extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
           </compilerArguments>
         </configuration>
</plugin>

發現版本信息需要完善,完善后如下:

<plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
         <!-- <version>3.6.2</version>-->
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
           <fork>true</fork>
          <!--以下javac的路徑為電腦實際jdk1.8的安裝路徑-->
            <executable>E:\software\jdk1.8\bin\javac</executable>
            <encoding>UTF-8</encoding>
            <compilerArguments>
              <extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs>
            </compilerArguments>
          </configuration>
        </plugin>

2、檢查IDEA系統配置jdk版本

1.png
2.png

3、再次執行命令$ mvn clean package -Dmaven.test.skip=true

3.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容