Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1

Background: JDK1.8 is used in this project

The following error occurred when compiling Maven project:

Failed to execute goal org.apache.maven.plugins :maven-compiler- plugin:3.1

The Maven plug-in is configured in POM as follows, and JDK1.8 is declared in the configuration:


Here’s ${java8_ The variable home} is in the settings.xml The configuration is as follows:

                <JAVA8_HOME>C:\Program Files (x86)\Java\jdk1.8.0_73</JAVA8_HOME>

Of course, it should be activated here, so settings.xml The file should also have the following configuration:


From the POM file, click Ctrl on the variable java8_ Home can jump to settings.xml To find its definition, it should be able to find the variable. The above problem is not because the variable cannot be found. I will add Java 8 in POM file_ The variable home is directly replaced by the actual path, that is, by

C:\Program Files (x86)\Java\jdk1.8.0_73\bin\javac

It’s strange to find that the compilation passed.

Reasons for disclosure:

Maven actually has a default warehouse. M2 warehouse and default warehouse settings.xml Configuration file, we are in this default settings.xml A Java 8 is also added to the file_ After the variables of home are compiled, they are passed. This means that when Maven is compiled, it is not my custom variables that I configured in idea settings.xml It’s the default one. Because there is no java8 in it, we can’t find it before_ Home, resulting in compilation failure

Summary: Maven should be found first when compiling settings.xml If it can’t be found, I will go to the “user settings file” configured under the settings option of idea settings.xml Documents.

Solution: delete the one Maven is looking for by default settings.xml In this way, the customized file will take effect


Similar Posts: