Java – enable lambda expressions

In the program

entities.stream().filter(m->m.getId()==id).findAny().get();

Where entities are lists Set all libraries and other SDKs to Java 8 After that, we will receive the following errors:

use -source 8 or higher to enable lambda expressions

Solution

This solves my problem by adding the following plug-in settings to my parent POM file

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>