【轉載原因:解決問題】
【轉載原文:https://blog.csdn.net/a499477783/article/details/78967586/】
版權聲明:本文爲博主原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。
本文鏈接:https://blog.csdn.net/a499477783/article/details/78967586
收起
出現如圖錯誤:
報錯信息:
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.
問題原因:
出現該問題的原因是由於使用了JAVA8的新特性,但是Language Level(最低可支持的版本)比較低,無法支持這些特性。比如設置的Language Level爲6.0,可是卻使用了8.0/9.0的新特性,6.0無法解析這些特性,因此IDE會報錯來提醒我們。
解決方法:
如果對最低支持版本有要求,沒辦法改動的話,那就只能放棄使用報錯部分的代碼。
如果對支持版本沒有要求的話,可以改動IDE的Language Level來消除錯誤。
使用ctrl+shift+alt+S,打開Project Structure,選中側邊欄的Modules,在Sources窗口中修改Language Level(必須大於等於報錯信息給出的level)。改動後,IDE錯誤消失。
Maven項目每個Module都有單獨的pom.xml,如果不在pom.xml中進行配置,則默認將Module的Language Level設置爲5。所以要在pom.xml文件中添加插件進行配置。
<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>