Usage of API documented as @since 1.8+”报错的解决办法

出现如图错误: 
报错信息 
报错信息: 
Usage of API documented as @since 1.8+ 
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.apache

问题缘由:

出现该问题的缘由是因为使用了JAVA8的新特性,可是Language Level(最低可支持的版本)比较低,没法支持这些特性。好比设置的Language Level为6.0,但是却使用了8.0/9.0的新特性,6.0没法解析这些特性,所以IDE会报错来提醒咱们。maven

解决方法:

若是对最低支持版本有要求,没办法改动的话,那就只能放弃使用报错部分的代码。 
若是对支持版本没有要求的话,能够改动IDE的Language Level来消除错误。ui

  • 使用ctrl+shift+alt+S,打开Project Structure,选中侧边栏的Modules,在Sources窗口中修改Language Level(必须大于等于报错信息给出的level)。改动后,IDE错误消失。 
    这里写图片描述spa

  • Maven项目每一个Module都有单独的pom.xml,若是不在pom.xml中进行配置,则默认将Module的Language Level设置为5。因此要在pom.xml文件中添加插件进行配置。.net

  • <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>
相关文章
相关标签/搜索