无法解决 IntelliJ 上关于项目语言级别的 -source 错误 [英] Can't resolve -source errors on IntelliJ with regards to Project Language Level

查看:27
本文介绍了无法解决 IntelliJ 上关于项目语言级别的 -source 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试在 Mac 上的 IntelliJ 上构建我的项目时遇到了这样的错误.

I am running into errors like these while trying to build my project on IntelliJ on Mac.

Error:(12, 39) java: diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)

Error:(122, 48) java: method references are not supported in -source 1.5
  (use -source 8 or higher to enable method references)

Error:(124, 51) java: lambda expressions are not supported in -source 1.5
  (use -source 8 or higher to enable lambda expressions)

查看此站点上的其他答案,这与项目语言级别太低有关.但是,我的设置如下:

Looking at other answers on this site, it has to do with Project Language Level being too low. However, mine is set to the following :

似乎我选择了正确的选项,但我仍然遇到相同的错误.我该如何解决这些问题.

Seems like I have the right option selected but I'm still getting the same errors. How do I resolve these issues.

如果我使用的是 JDK 11.0.1,这是日志的第一部分:

Here is the first part of the log if I used JDK 11.0.1 :

Information:java: JPS build failed to load optimized file manager for javac:
java.lang.NoClassDefFoundError: com/sun/tools/javac/util/DefaultFileManager
java.lang.NoClassDefFoundError: com/sun/tools/javac/file/JavacFileManager
Information:java: Errors occurred while compiling module 'notification-processor'
Information:javac 8 was used to compile java sources
Information:Module "notification-processor" was fully rebuilt due to project configuration/dependencies changes
Information:2018-11-07, 4:38 PM - Compilation completed with 19 errors and 4 warnings in 3 s 490 ms
Warning:java: class org.jetbrains.jps.javac.ast.ExternalRefCollectorCompilerToolExtension : com/sun/source/util/TaskListener
Warning:java: source value 1.5 is obsolete and will be removed in a future release
Warning:java: target value 1.5 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.

如果我使用 JDK 8,这是日志的第一部分:

Here is the first part of the logs if I use JDK 8 :

Information:java: Errors occurred while compiling module 'notification-processor'
Information:javac 1.8.0_191 was used to compile java sources
Information:Module "notification-processor" was fully rebuilt due to project configuration/dependencies changes
Information:2018-11-07, 4:39 PM - Compilation completed with 19 errors and 3 warnings in 2 s 858 ms
Warning:java: source value 1.5 is obsolete and will be removed in a future release
Warning:java: target value 1.5 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.

推荐答案

请确保您没有在模块设置中覆盖语言级别:

Please make sure that you do not override language level in module settings:

和编译器设置

这篇关于无法解决 IntelliJ 上关于项目语言级别的 -source 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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