因为 Maven 工程默认为 1.5 版本,如果我们想使用 jdk 1.8 才有的特性,比如:Lambda 表达式,接口的默认实现方法,我们要将版本改为 1.8。
具体的实现方法是在 pom.xml 文件中加上这一段代码。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
pom.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<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>org.geekbang</groupId>
<artifactId>thinking-in-spring</artifactId>