java: 无法访问org.springframework.boot.SpringApplication 错误的类文件: /C:/Users/xx/.m2/repository/org/spring

错误描述

java: 无法访问org.springframework.boot.SpringApplication

错误的类文件: /C:/Users/lvgr8/.m2/repository/org/springframework/boot/spring-boot/3.1.0/spring-boot-3.1.0.jar!/org/springframework/boot/SpringApplication.class

类文件具有错误的版本 61.0, 应为 52.0

请删除该文件或确保该文件位于正确的类路径子目录中。

在这里插入图片描述

报错的原因

出现这个报错的原因就是创建springboot项目的时候,springboot和选择的JDK版本没有对应上

springboot3.0系列只支持JDK17的版本(一般pom.xml里面的JDK版本也要改为17)

spring2.0系列默认支持JDK8的版本(常用)

问题处理

修改springboot的版本号

在这里插入图片描述

修改后成功运行

在这里插入图片描述

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/eb16ca14b1.html