Maven uses JDK1.5 to compile by default
The diamond operator, referring to a new feature of JDK1.7
List<String> list = new ArrayList<String>(); // 老版本写法
List<String> list = new ArrayList<>(); // JDK1.7写法
So Maven uses JDK1.5 to compile by default and definitely doesn't know this thing
You can add the following to your pom.xml
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Or you can configure the Maven compilation plugin directly in pom.xml, like the following
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>