0

It comes from https://mybatis.org/mybatis-3/getting-started.html.

try (SqlSession session = sqlSessionFactory.openSession()) {
   // do work
}

when I copy the code into editior . I get an error

try with resources are not supported at language level 5

how comes the problem?

Tim
  • 322
  • 1
  • 3
  • 14
  • Also have a look at the [doc](https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html) – Lino Jan 27 '20 at 13:26
  • 1
    As for the "not supported at language level 5", that sounds like an IDE problem to me. Make sure you've configured your project to use Java 7 or later. – Slaw Jan 27 '20 at 13:28
  • I fixed the problem by add org.apache.maven.plugins maven-compiler-plugin 8 8 to pom.xml for maven . not sure what's that but It works for me. – Tim Jan 27 '20 at 13:33
  • It means you're targeting Java 8. Your IDE probably read the `pom.xml` file and auto-configured itself for development in Java 8. – Slaw Jan 27 '20 at 13:51

0 Answers0