Specifying the Java version for the Compiler plugin

When we created a new project in Eclipse, you would have observed the following warning:

Specifying the Java version for the Compiler plugin

Why does this error occur? This is because the Maven Compiler plugin, by default, considers the source and target Java version to be 1.5 (for backward compatibility reasons).

Let us resolve this warning.

How to do it...

Let us assume you have configured Java 8 as the default Java runtime in Eclipse, and perform the following steps:

  1. Open the Eclipse project.
  2. Add the following configuration to the Maven Compiler plugin:
     <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> ...

Get Apache Maven Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.