Intellij - Unable to use newer Java 8 classes - Error : “Usage of API documented as @since 1.6+..”

前端 未结 8 995
我寻月下人不归
我寻月下人不归 2020-11-28 19:00

I\'m trying to use a java.lang.function.Function in my java 8 code base, but i keep getting the following error in Intellij.

Usage of API

相关标签:
8条回答
  • 2020-11-28 19:30

    Maybe your config of repository has properties include compiler Version. examine settings.xml file.

    <jdk>1.8</jdk>
    </activation>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
    </properties>
    
    0 讨论(0)
  • 2020-11-28 19:32

    I just fixed it as follows:

    Right click the project -> Open Module Settings -> Modules -> Sources -> 8 or higher

    And then

    If still encounter the error and using maven, you have to add the build configuration in your pom.xml:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    0 讨论(0)
提交回复
热议问题