如何在Intellij中更改所有项目的项目语言级别 [英] How to change project language level for all project in Intellij

查看:2583
本文介绍了如何在Intellij中更改所有项目的项目语言级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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:


Intelij上的任何新手都应该记住,不选择Maven
或Gradle与Java项目创建一起设置必须使用
默认包(src / main / test和src / main / java)结构;对于eclipse用户来说,这是一个真正令人头疼的问题,首次使用Intelij开始

any newbie on Intelij should remember that not selecting either Maven or Gradle in conjunction with your Java project creation will not setup the default package (src/main/test and src/main/java) structures necessary; for eclipse users this is a real head scratcher when first starting to use Intelij.

这篇关于如何在Intellij中更改所有项目的项目语言级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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