【异常】jdk21升级,asm报错Unsupported class file major version 65

错误信息

Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [C:\App.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 65at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:60)at org.springframework.core.type.classreading.SimpleMetadataReader.(SimpleMetadataReader.java:49)at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:429)... 20 common frames omittedCaused by: java.lang.IllegalArgumentException: Unsupported class file major version 65at org.springframework.asm.ClassReader.(ClassReader.java:199)at org.springframework.asm.ClassReader.(ClassReader.java:180)at org.springframework.asm.ClassReader.(ClassReader.java:166)at org.springframework.asm.ClassReader.(ClassReader.java:287)at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:57)... 24 common frames omitted

排查 发现是这个类导致的

org.springframework.asm.ClassReader

在代码里写死了限制jdk版本

直接重写该类

把这四行注释掉

问题解决

或者 升级

升级spring-core版本,整体springboot升级