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+..”
相关文章推荐
- HBase-1.0.1.1的Java API使用记录
- apache使用cronolog日志轮询无法启动排查错误记录
- java 使用eclipe时书写异常时出现无法访问du的错误
- javac 及 java命令的使用问题(错误或无法加载主类)
- Intellij Error:usage of api documented as @since 1.6+Error:java: Compilation failed: internal java c
- 使用SDL2出现 “error LNK2019: 无法解析的外部符号 _SDL_main,该符号在函数 _main 中被引用” 时的可能错误记录
- 很好的一篇文章,我使用java 自带的ldap api 一直报32错误,使用novell后正常
- 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“java.lang.RuntimeException: Could not generate DH key
- [置顶] 使用java命令运行class文件提示“错误:找不到或无法加载主类“的问题分析
- com.microsoft.sqlserver.jdbc.SQLServerException: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“java
- 使用java命令运行class文件提示“错误:找不到或无法加载主类“的问题分析
- 64位win7下使用C_API编写mysql程序的错误及解决办法记录
- myeclipse里工程的jdk使用的1.7版本,其中java compiler最高只能选到1.6的问题(在maven工程中出现的问题) -- 记录
- 使用java命令运行class文件提示“错误:找不到或无法加载主类“的问题分析
- mac 下 使用 java运行 class 文件 总是提示 “错误: 找不到或无法加载主类”的解决方法
- 关于使用极光推送报 java.lang.ClassNotFoundException: com.google.gson.Gson”错误记录
- oracle10g登录em后,提示“java.lang.Exception: Exception in sending Request :: null” 错误,导致EM无法使用
- 17年2月26日Java后台学习记录,Mysql 多个timestamp,xml中使用小于号,Mybatisdao接口多个参数函数错误
- Java使用中菜鸟常犯的一些错误记录
- 解决java连接SQLSERVER数据库之驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:Could not generate DH keypair”。