您的位置:首页 > 编程语言 > Java开发

Intellij – 无法使用较新的Java 8类 – 错误:“API的用法记录为@since 1.6+

2017-08-13 14:59 429 查看


问题描述

我试图在我的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重新导入或构建它。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>


否则,从下面的路径中选择java编译器和语言级别。

文件>项目结构>项目设置>模块>你的模块名称>来源>语言水平>选择你需要的那个。



从这里改变语言水平: –




第三种解决方案

实际上,如果您使用Maven并且您的
pom.xml
项目属性配置正确
<project xmlns="...>
....
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
...
</project


您可以将Maven参数重新导入到
intellij-idea
项目中 – 右键单击​​项目根目录,然后在底部的
Maven
-> Reimport





参考文献

Intellij
– Unable to use newer Java 8 classes – Error : “Usage of API documented as @since 1.6+..”
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐