java - 无法解决 IntelliJ 上关于项目语言级别的 -source 错误
问题描述
我在尝试在 Mac 上的 IntelliJ 上构建我的项目时遇到了类似的错误。
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)
查看此站点上的其他答案,这与项目语言级别太低有关。但是,我的设置如下:
似乎我选择了正确的选项,但我仍然遇到同样的错误。我该如何解决这些问题。
如果我使用 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,这是日志的第一部分:
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.
解决方案
推荐阅读
- cmake - cmake函数的并行执行?
- c# - 在c#中找到具有相同值的字典中的最小键
- vhdl - 为什么我的七段显示器只显示 0?
- javascript - 如何使用javascript获取已删除项目的值
- c# - 实现类以处理实时数据
- javascript - 修复不和谐 !avatar 命令的代码
- python - 将两个不同列表中的值顺序分配给python数据框中的列
- visual-studio - 让 Premake 生成一个引用现有 .props 文件的 vcxproj 文件
- c - malloc:从内存中获取信息
- angular - Docker 上的 Jenkins 开始在 Docker 上构建 Angular 应用程序