Java: release version 5 is not supported

mistake

Java: release version 5 is not supported

detailed error

A classmate found a microservice project (built based on maven) on github, started the second open, imported the project and ran the console and reported an error
Java: release version 5 is not supported, the author modified the project structure ( File FileFile → \rightarrow P r o j e c t S t r u c t u r e Project Structure P ro j ec tSt r u c t u re ) and settings (File FileFile → \rightarrow S e t t i n g s Settings S e tt in g s ), the error is still reported

solution

Add the following configuration to the pom.xml dependency file

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Error reason

The error message "Java: release version 5 not supported" indicates that the project uses the release version of Java 5, but the current environment does not support this version.

solve the cause

Ensure that the project compiles and runs under Java 8 by setting the project's compiler source and target versions to 1.8. In this way, it can be consistent with the Java version of the current environment and avoid error reporting.
The author here explains in detail the addition of the following configuration to the pom.xml dependency file

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
<properties>
</properties>

Tags are used to define the properties of an item. In the above solution, we added two attributes to the label:

<maven.compiler.source>1.8</maven.compiler.source>

<maven.compiler.source>: Specifies the Java version of the project source code. Here, we set it to 1.8, which means that the source code is written using Java 8 syntax and features.

<maven.compiler.target>1.8</maven.compiler.target>

<maven.compiler.target>: Specifies the Java version of the compiled bytecode. Again, we set it to 1.8 to ensure that the compiled code is compatible with Java 8.
By setting these two properties to 1.8, we tell Maven to compile with Java 8's compiler and generate a Java 8-compatible bytecode file. This can solve the error problem and ensure that the project compiles and runs correctly in the Java 8 environment.

references

Solution reference error "Java: release version 5 is not supported" correct solution solution
reason reference chatgpt

It’s not easy
to be original, please indicate the source
if it’s helpful to you, don’t forget to like it and support it
insert image description here

Guess you like

Origin blog.csdn.net/T_Y_F_/article/details/131317847