完整错误是:Failed to read candidate component class:ASM ClassReader failed to parse class file - nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 65[ restartedMain] o.s.boot.SpringApplication : Application run failed
错误的意思就是项目不支持65版本的jdk,65对应的Java21版本
这个项目用到的jdk版本是18,所以在idea中切换jdk版本为18然后修改maven配置为18就好了
step1:在idea中找到file点击project structure,在侧边栏选择project,然后修改SDK
step2:在侧边栏点击modules修改
step3:在setting中修改jdk编译器为18
step4:去maven的配置文件setting.xml找到profile修改为18
<profile>
<id>jdk-version-18</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
</properties>
</profile>
还有一种可能是:spring boot框架和jdk版本不兼容
错误:org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet:Unsupported class file major version 62
解决:62表示jdk版本是18,将spring boot框架版本改为2.7.2