问题描述
我正在使用Intellij。这很好,但是当我创建一个新项目或导入项目时,默认项目语言级别设置为6(接口中的@override)。但是我想把它设置为8(Lambdas,类型注释等)。我怎样才能做到这一点?我尝试更改其他设置 - >默认项目结构中的设置,并将项目语言级别设置为8,但没有运气。请有人帮帮我我添加了一个屏幕截图。
I am using Intellij. It is good, but when I create a new project or import a project the default project language level set to 6 (@override in interfaces). But I want to set it 8 (Lambdas, type annotations etc). How can I do that? I have tried change the settings in "Other Settings" -> "Default Project Structure" and the set the project language level to 8, but no luck. Please someone help me. I have added a screen shoot.
- 我正在使用Intellij 14.0.2
推荐答案
我将设置更改为Java 8以上建议......-> 默认项目结构。
I changed the settings to Java 8 as advised above...->Default Project Structure.
我继续无法在编辑器中编写Lambda的而没有错误。
当我创建项目时,我选择了Gradle作为构建工具。
出于某种原因,我的Java / Gradle项目将build.gradle文件中的源兼容性设置为1.5(可能是因为我的默认设置最初设置为1.5 ...我不知道因为我没有费心去复制它):
When I created the project, I chose Gradle as the build tool.For some reason my Java/Gradle project had the source compatibility in the build.gradle file set to 1.5 (maybe because my default was originally set to 1.5...I don't know as I did not bother to reproduce it):
apply plugin: 'java'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
更改 sourceCompatibility 到1.8解决了这个问题,因为对gradle文件的更新也会触发项目构建。
Changing the sourceCompatibility to 1.8 solved the problem, since the update to the gradle file also triggers a project build.
Word to the wise:
这篇关于如何在Intellij中更改所有项目的项目语言级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!