IntelliJ IDE gives error when using Try-Catch with Resources

前端 未结 5 684
栀梦
栀梦 2020-12-13 08:30

I am attempting to use JDK 7\'s \"try-catch with resources\" statement; IntelliJ highlights my resource line, saying

Try-with-resources are not supp

5条回答
  •  暖寄归人
    2020-12-13 09:14

    The only way this error will occur is if your module's language level isn't set to 1.7+. This needs to be set in either your IntelliJ project/module settings, the project's pom.xml file, or both.

    IntelliJ

    enter image description here

    Maven

    
      1.7
      1.7
    

    Module settings can override project settings; if setting this at the project level and you have a specific issue in a module, check the module settings as well.

提交回复
热议问题