jdk21升级,asm报错Unsupported class file major version 65

环境

jdk21升级,asm报错,spring-core版本5.3.18,项目springboot版本为2.6.6

报错明细

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 [F:\xxx\App.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 65
	at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:60)
	at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(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 omitted
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 65
	at org.springframework.asm.ClassReader.<init>(ClassReader.java:199)
	at org.springframework.asm.ClassReader.<init>(ClassReader.java:180)
	at org.springframework.asm.ClassReader.<init>(ClassReader.java:166)
	at org.springframework.asm.ClassReader.<init>(ClassReader.java:287)
	at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:57)
	... 24 common frames omitted

本来还以为是asm包的问题,还特意把asm升级到了9.6,但不是因为那个原因,而经排查是因为spring-core5.3.18版本最高支持jdk19导致的
支持版本写死了,在这里:
org.springframework.asm.Opcodes#V19
版本校验:
org.springframework.asm.ClassReader#ClassReader(byte[], int, boolean)
文件位置:
D:/xxx/maven_repository/org/springframework/spring-core/5.3.18/spring-core-5.3.18-sources.jar!/org/springframework/asm/ClassReader.java:197

处理措施

升级spring-core版本,整体springboot升级
浏览spring.io官网

点击Projects → SpringBoot
在这里插入图片描述

现阶段各主流版本:

在这里插入图片描述

支持时间:

在这里插入图片描述

升级

这里可以选择升级到springboot2.7.x,或者因为选择jdk21,选择直接将springboot干到3.2.x一劳永逸

将springboot项目升级后,刷新项目,使用maven重新import

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.18</version>
        <relativePath/>
    </parent>

项目成功运行

回头再看spring-core版本:5.3.31

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值