发布于 3年前

intellij 出现“Usage of API documented as @since 1.6+”的解决办法

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

File ->Project Structure->Project Settings -> Modules -> 你的Module名字 -> Sources -> Language Level->选个默认的就行。

1、error 1:Intellij Error:usage of api documented as @since 1.6+

错误场景:

开发工具:Intellij

在使用最新的Java8库的时候(我用的是Date.toInstant() ),在调用该方法的地方会有错误提示:

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

问题解决:

查阅资料发现这可能是其他项目的设置影响了编译器的等级。当编译器发现源代码和目标Java版本与设置的编译版本不同时,便会报这个错误。

要解决该问题,需作如下配置:Flie -> Project Structure -> Project Settings -> Modules -> "Your Module Name" -> Sources ->Language Level ,然后将其更改为所需级别,即8或"项目默认语言级别"。

2、error 2: Error:java: Compilation failed: internal java compiler error

问题解决:按照方法1修改语言级别后,Maven-->Reimport, 再次编译,问题会还原,所以这样不能根本解决问题。

需要做的是在Maven依赖配置文件pom.xml中添加complier插件,并且指定版本,就不会再报错了:

<build>  

    <plugins>  

        <plugin>  

            <groupId>org.apache.maven.plugins</groupId>  

            <artifactId>maven-compiler-plugin</artifactId>  

            <version>3.6.0</version>  

            <configuration>  

                <source>1.8</source>  

                <target>1.8</target>  

            </configuration>  

        </plugin>  

    </plugins>  

</build>  

相关文章

©2020 edoou.com   京ICP备16001874号-3