Try-with-resources are not supported at language level '5'

Try-with-resources are not supported at language level '5'
没有指定maven版本导致 的

指定maven版本


没有指定maven版本导致 的

指定maven版本就可以

//再try()中写代码报错
try (SqlSession session  = sqlSessionFactory.openSession()) {
            
}

解决方法:

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-compiler-plugin</artifactId>
     <configuration>
         <source>8</source>
         <target>8</target>
     </configuration>
</plugin>
posted @ 2022-08-18 11:37  化羽羽  阅读(228)  评论(0编辑  收藏  举报