Java: compilation failed: internal java compiler error and invalid source distribution resolution

Reason: it is mainly because the JDK version is inconsistent        

1. The compiled version does not match. 2. The current project JDK version does not support        

1. First, view the JDK of the project

File -> Project Structure-> Project Settings -> Project

                  1.8 must correspond to 8

Check whether the JDK of the current project (module) is the same as that of the project

2. Maven is used in the idea to build the project. The target bytecode version is automatically changed to 1.5     Because no JDK is specified in maven, it will be scanned as the default JDK version   View and set the java compiler version (target bytecode version)

File–> Setting–> Build,Execution,Deployment–>Compiler–> Java compiler sets the corresponding module

         The appropriate version of target bytecode version, such as JDK1.8     Change 1.5 above to 1.8

Solution:

Add Maven compiler plugin to pom.xml so that it will not automatically become 1.5

     <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>UTF-8</encoding>
                </configuration>
      </plugin>

Read More: