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:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${JAVA8_HOME}/bin/javac</executable>
</configuration>
</plugin>
Here’s ${java8_ The variable home} is in the settings.xml The configuration is as follows:
<profile>
<id>custom-compiler</id>
<properties>
<JAVA8_HOME>C:\Program Files (x86)\Java\jdk1.8.0_73</JAVA8_HOME>
</properties>
</profile>
Of course, it should be activated here, so settings.xml The file should also have the following configuration:
<activeProfiles>
<activeProfile>custom-compiler</activeProfile>
</activeProfiles>
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:
- Automatic version change of IntelliJ idea language level and Java compiler
- How to Solve IDEA maven Error:Perhaps you are running on a JRE rather than a JDK
- [Solved] NB: JAVA_HOME should point to a JDK not a JRE
- [Solved] MAVEN-COMPILER-PLUGIN Compile Error: FATAL ERROR: UNABLE TO FIND PACKAGE JAVA.LANG IN CLASSPATH OR BOOTCLASSPATH
- [Solved] Maven Error: No compiler is provided in this environment. Perhaps you are running on a JRE rather t…
- New Maven project — pom.xml error [How to Solve]
- [Solved] Error:java: error: release version 5 not supported & Switch Unrecognized String
- Maven [error] no longer supports source option 5. Please use version 7 or later
- [IDEA] Maven Run Project Error: Diamond operator is not supported in – source 1.5″
- How does IntelliJ idea use Maven Tomcat plug to run web projects