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:
- Solutions to error: Java: compilation failed: internal java compiler error
- Java idea Compilation failed: internal java compiler error
- Idea error: Java: compilation failed: internal java compiler error
- IntelliJ idea error: Java: compilation failed: solution to internal java compiler error
- When using idea to start a project, an error is reported: Error:java : Compilation failed: internal java compiler error
- Error:java: Compilation failed: internal java compiler error
- Idea Tomcat start error Error:java : Compilation failed: internal java compiler error
- idea Error:java: Compilation failed: internal java compiler error
- Error: (44,73) lambda expression and XML are not supported in Java: – source 1.7 Error:java : Compilation failed
- Compliation failed : internal java compiler error
- Error in idea compilation: java.lang.OutOfMemoryError Java heap space and java.lang.StackOverflowError
- appear Error:java : javacTask: source release 1.7 requires target release 1.7
- Ubuntu: Failed to initialize compiler: object java.lang.Object In compiler mirror not found
- Maven invalid source release 11
- Fatal error matching: invalid target distribution: 11
- ninja Compiling the C compiler identification source file CMakeCCompilerId.c failed
- Eclipse .java File Syntax error, parameterized types are only available if source level is 1.5 or
- java.lang.Error: Unresolved compilation problems
- How to Fix:java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/methods/HttpPost