尝试使用该语言级别不支持的资源 [英] Try With Resources Not Supported at This Language Level

查看:122
本文介绍了尝试使用该语言级别不支持的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IntelliJ IDEA Ultimate 2016.2.1,已将Project SDK设置为我的1.8版本,将Project Language Level设置为8,将Module SDK设置为我的1.8版本,并将JDK的主路径设置为/Library/Java/JavaVirtualMachines/jdk1. 8.0_91.jdk/Contents/Home.

I'm using IntelliJ IDEA Ultimate 2016.2.1, have set Project SDK to my 1.8 version, Project Language Level to 8, Module SDK to my 1.8 version, and JDK home path to /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home.

我已经重新启动了IDE.

I have restarted the IDE.

不过,对于这种语言级别不支持的try-with-resources,我仍然收到难看的警告.我在IntelliJ中使用的语言没有低于8级,因此这不可能是由于某些东西没有刷新而引起的.我正在使用gradle构建配置-已清理构建并尝试运行-说我正在运行1.5,但我不知道提到的1.5.在build.gradle中,我正在使用:

Still, I am getting ugly warnings about try-with-resources not supported at this language level. I have not used less than language level 8 in IntelliJ so this can't be due to something not refreshing. I am using a gradle build configuration - cleaned built and tried to run - says I'm running 1.5 but I can't figure out where 1.5 is mentioned. In build.gradle i'm using:

 apply plugin: 'java'
 apply plugin: 'application'
 sourceCompatibility = 1.8

我应该提交IntelliJ错误还是仍然遗漏某些东西?

Should I file an IntelliJ bug or am I still missing something?

在IntelliJ系统之外的终端运行gradle可以正常运行.因此,问题与IntelliJ有关.

Running gradle in termianl outside of IntelliJ's system runs it fine. So the problem is IntelliJ related.

推荐答案

我发现IntelliJ有时会将模块默认设置为与设置的项目SDK不匹配的语言级别.尝试在项目浏览器中的模块上单击鼠标右键,然后选择模块设置,然后选择语言级别"选项卡.如果将其设置为Java 5,则将其更新为Java 8.

I have found that IntelliJ sometimes defaults modules to language levels that don't match the set project SDK. Try right clicking on the module in the project explorer and select module settings and then the language level tab. If that is set to Java 5 then update it to Java 8.

这篇关于尝试使用该语言级别不支持的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆