intellij-idea - Intellij - 无法使用较新的 Java 8 类 - 错误 : "Usage of API documented as @since 1.6+.."

标签 intellij-idea java-8

我正在尝试在 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/

相关文章:

java - 将多个流优化为单个循环

java - 如何在 JAVA 8 中的 lambda 函数中测试需要用户输入的代码?

grails - Grails Java 8开发人员模式支持

intellij-idea - IntelliJ IDEA 版本 "Linux"和 "Linux, without JDK"之间的区别

gradle - IntelliJ IDE 2018.3 Ultimate + Gradle 5.2.1和仅可编译

git - 提示符 "Do you want to add the following file to Git?"究竟做了什么?

java-8 - 当我在 Ubuntu 上构建 OpenJDK9 时,运行 "configure"并发现大量缺少的依赖项,这有关系吗?

unit-testing - 在其自己的 JVM 中与每个测试类并行收集并运行所有 junit 测试(按类并行化,而不是按方法并行化)

android - 带有 SBT : ANDROID_HOME not found 的 IntelliJ IDEA

java - 如何在Java反射中获取字段值