Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to run mvn clean install but I am facing following error Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure in Java. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
- How This Error Occurs ?
- How 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 ?
- Solution 1: add the following properties
- Solution 2: add this code in effective POM
- Solution 3: Using org.projectlombok:lombok
- Summary
How This Error Occurs ?
I am trying to run mvn clean install but I am facing following error.
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)
diamond operator is not supported in -source 1.5 [ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] 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 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 ?
How 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 ?
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. Now, Your problem might be solved. Second solution is If You are using org.projectlombok:lombok then You need to update org.projectlombok:lombok version to 1.16.22 or 1.18.12, Just like this. And my error solved.
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. Now, Your problem might be solved. Second solution is If You are using org.projectlombok:lombok then You need to update org.projectlombok:lombok version to 1.16.22 or 1.18.12, Just like this. 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>
Now, Your problem might be solved.
Solution 2: add this code in effective POM
Just need to add this code in effective POM.xml file.
<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 update org.projectlombok:lombok version to 1.16.22 or 1.18.12, Just like this.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.22</version>
</dependency>
And my error solved.
Summary
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read