Error recurrence
I installed maven 3.5.0 on my machine and created a maven project in eclipse. Pom.xml is configured as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>zhangchao</groupId> <artifactId>testVertx</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <!-- 一些依赖 --> </dependencies> </project>
Right click the project – > Maven -> Update Project … -> The OK code always gives error prompts, which are as follows: lambda expressions are allowed only at source level 1.8 or above
Solutions
To change the pom.xml configuration, there are two key statements:
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target>
Add these two statements to the properties tag pair, and the changed code is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>zhangchao</groupId> <artifactId>testVertx</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <dependencies> <!-- 一些依赖 --> </dependencies> </project>
Right click the project again – > Maven -> Update Project … -> OK 。
if update project doesn’t work, right-click – > Run as -> Maven build… -> In goals, enter clean compile – > RUN
There should be no error prompts at this time