usage of api documented as @since 1.8+ 解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/pmdream/article/details/81382765

今天在写Base64转码的时候,遇到的这个问题。

import java.util.Base64;显示标题的错误

网传解决办法:

问题原因:

Java版本比较高,但是Language Level(最低可支持的版本)比较低,无法支持这些特性。比如设置的Language Level为6.0,可是却使用了8.0/9.0的新特性,6.0无法解析这些特性,因此IDE会报错来提醒我们。

解决方法:

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

但是按照这种方法,改了project structure 中model的source的 Language Level,报错没有消除

个人找到的解决办法:

pom.xml中加入

<build>
        <finalName>test</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

        </plugins>
    </build>

 加入插件,Maven进行清理安装即可

  <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>

猜你喜欢

转载自blog.csdn.net/pmdream/article/details/81382765
今日推荐