解决org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version

Solve the compilation version problem

Run the scene

Execute clean in the project, and then execute install to report an error, the error is as follows

org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Problem Description

org/springframework/boot/maven/RepackageMojo is compiled by a newer version of Java Runtime (class file version 61.0), which can only recognize class file versions below 52.0

Cause Analysis

According to the corresponding table, this file is compiled by java 17 version, but now the system can only recognize the version below java 8, the java version is inconsistent and the packaging fails, you need to set a version in the packaging plug-in of the wrong module.

java correspondence table

49 = Java 5
50 = Java 6
51 = Java 7
52 = Java 8
53 = Java 9
54 = Java 10
55 = Java 11
56 = Java 12
57 = Java 13
58 = Java 14

insert image description here
The above is a screenshot of the error, there are two places that need to be confirmed

The one below can see which module has the problem. The one above can see that the version of spring-boot in the packaged plug-in is unknown, which leads to the reference to the latest version, causing inconsistencies.

Solution

Find the pom file of the wrong module, set the version of the packaging plug-in, keep it with other modules, refresh maven, and pack it again
insert image description here

Summarize

Because the version of the packaged plug-in of some modules was not added before, it can be used normally, but it suddenly failed today. Later, it was found that spring boot version 3.0 was officially released recently. Version 3.0 is based on java 17. If it is not specified, it will refer to the latest version by default. This leads to this kind of problem, so when you do it, you must specify the version of the packaged plug-in for all modules to avoid this kind of problem. Of course, this version number is best defined in the overall pom file, and in the submodule Just refer to it directly, instead of defining it one by one in each submodule.

Guess you like

Origin blog.csdn.net/zch981964/article/details/131435507