Book Image

Apache Maven Cookbook

Book Image

Apache Maven Cookbook

Overview of this book

Table of Contents (18 chapters)
Apache Maven Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Specifying the Java version for the Compiler plugin


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

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>
            <version>3.2</version>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </plugin>
        </plugins>
  3. Alternately, add the following properties...