当前位置:   article > 正文

spring cloud项目启动报错:RefreshBootstrapRegistryInitializer has been compiled by a more recent version of_org/springframework/cloud/bootstrap/refreshbootstr

org/springframework/cloud/bootstrap/refreshbootstrapregistryinitializer has

问题

新建了一个spring cloud项目,简单引入网关的依赖包,结果项目启动报错,信息如下:
在这里插入图片描述

Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.BootstrapRegistryInitializer : org.springframework.cloud.bootstrap.RefreshBootstrapRegistryInitializer
	at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:475)
	at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:457)
	at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:450)
	at org.springframework.boot.SpringApplication.getBootstrapRegistryInitializersFromSpringFactories(SpringApplication.java:297)
	at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:285)
	at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:266)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
	at com.example.gatewaydemo.GatewayDemoApplication.main(GatewayDemoApplication.java:10)
Caused by: java.lang.UnsupportedClassVersionError: org/springframework/cloud/bootstrap/RefreshBootstrapRegistryInitializer 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
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

分析

查看了网上博客,都说jdk的版本问题,检查完idea的jdk设置和pom文件的jdk版本设置,都没发现问题。

最后发现的问题是spring cloud的版本和springboot版本没对应
修改前pom文件如下:
在这里插入图片描述
springboot版本用的是2.5.5
spring cloud版本用的是2022.0.1
查看官网:https://spring.io/projects/spring-cloud
在这里插入图片描述
决定降低spring cloud的版本,修改后pom文件如下:
在这里插入图片描述
项目成功启动
在这里插入图片描述

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号