最先出现这个问题我以为是我的jdk没有设置为1.8,但是在File >> Project Structure >> Project language level确实是8。
依然是:Try-with-resources are not supported at language level '5’错误。
后来更改pom.xml 中添加以下配置就好了:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>