我正在尝试在 java 8 代码库中使用 java.lang.function.Function
,但我在 Intellij 中不断收到以下错误。
Usage of API documented as @since 1.6+ This inspection finds all usages of methods that have @since tag in their documentation. This may be useful when development is performed under newer SDK version as the target platform for production
我似乎有正确的项目和编译器设置
项目设置:(文件 -> 项目结构)
Project Settings -> Project -> Project SDK = Java 1.8
Project Settings -> Project -> Project Language Level = 8 - Lambdas, Type Annotations etc
编译器设置:(文件 -> 设置)
Build, Execution, Deployment -> Compiler -> Java Compiler -> Project Bytecode Version : 1.8
Build, Execution, Deployment -> Compiler -> Java Compiler -> Per module Bytecode Version -> Target Bytecode Version : 1.8
问题是什么?
最佳答案
根据 Bastien Jansen 评论编辑了答案。
似乎还有另一个项目设置影响编译器级别。此问题的一个微妙迹象是,当您的编译器开始提示源和目标 java 版本与您在编译代码时指定的版本不同时
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.
要摆脱这个,你需要开放
文件 -> 项目结构 -> 项目设置 -> 模块 -> “您的模块名称” -> 源 -> 语言级别
并将其更改为所需的级别,即 1.8 或项目默认语言级别
关于intellij-idea - Intellij - 无法使用较新的 Java 8 类 - 错误 : "Usage of API documented as @since 1.6+..",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37787079/