Solve Intellij idea Error: java: invalid source release: 1.8

created at 09-27-2021 views: 256

Errors in the compilation of the new project are as follows:

error screenshot

The reason lies in the error caused by the inconsistency between the target bytecode version of the module and the actual compiler version.
Regardless of the three seven twenty one, change all jdk versions to the same, first press the shortcut key ctrl+shift+alt+s:

project sdk

After the project sdk is changed,  also change the sdk of the module:

 change module sdk

project sdk

Finally, press the shortcut key ctrl+shift+s to modify the Java Compiler configuration, unify the byte code version and the sdk version, don't care who is high and which is low, it will be no problem if it is the same:

java compiler

Of course, if you are a maven project, you may also need to change the jdk version configuration of the pom.xml file:

<build>  
    <plugins>  
        <plugin>  
            <groupId>org.apache.maven.plugins</groupId>  
            <artifactId>maven-compiler-plugin</artifactId>  
            <configuration>  
                <source>1.7</source>  
                <target>1.7</target>  
            </configuration>  
        </plugin>  
    </plugins>  
</build>  
created at:09-27-2021
edited at: 09-27-2021: