Maven Compile failed for lambda or method references

Hi, all:

The Maven plugin in pom.xml can fail your compile with messages like this:

lambda expressions are not supported in -source 1.5 and/or method references are not supported in -source 1.5.

This happens even if your environment is purely JDK 8 (Eclipse, Maven etc).

It turns out the default plugin source is 1.5! So it would fail the compile right off the bat.

An easy fix is to add the source and target to be JDK 8 like this:


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>


It works greatly with this source/target explicitly set.

-Tony

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s