How To Fix “Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure”?
Are you having problems with the issue “Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure“? How to fix it? In today’s article, I will provide solutions for you to solve the issues. Please follow the below steps to get the problem resolved now
How did “Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure” occur?
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure
When you work with JAVA, you may get the issue Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure. Don’t worry, we are here to provide you solutions in order to resolve your problem.
How to fix “Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure”?
To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure Error Here problem is Maven doesn’t have a source that will allow to compile the diamond operators So that we need to configure maven-compiler-plugin itself So Just add the following properties. This might solve your problem. The second solution is to change org.projectlombok:lombok to 1.16.22. And my error solved.
Solution 1: Add the following properties
Here problem is Maven doesn’t have a source that will allow to compile the diamond operators So that we need to configure maven-compiler-plugin itself So Just add the following properties.
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
You might now have the solution to your problem.
Solution 2: Add this code to an effective POM
Simply add the code to your effective POM.xml.
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Solution 3: Using org.projectlombok:lombok
If you are using org.projectlombok:lombok, then you need to upgrade org.projectlombok:lombok to 1.16.22/1.18.12.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.22</version>
</dependency>
And my error solved.
Final words
The above are useful solutions that can help you fix “Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure” problem, if you can’t solve it well. Please leave a message.