IDEA软件报错内容:
问题描述
我试图在我的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.
要摆脱这一点,你需要开放
File -> Project Structure -> Project Settings -> Modules -> “Your Module Name” -> Sources -> Language Level
并将其改为所需的级别,即1.8或默认项目默认语言级别
次佳解决方案
如果您使用maven,然后在配置pom.xml文件中添加以下行,然后从maven重新导入或构建它。
文件>项目结构>项目设置>模块>你的模块名称>来源>语言水平>选择你需要的那个。
intellij-idea,java-8
从这里改变语言水平: –
intellij-idea,java-8
第三种解决方案
实际上,如果您使用Maven并且您的pom.xml项目属性配置正确
<project xmlns="…>
…
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
…
</project
您可以将Maven参数重新导入到intellij-idea项目中 – 右键单击项目根目录,然后在底部的Maven -> Reimport。
intellij-idea,java-8