异常解决:java.lang.NoClassDefFoundError: org/springframework/boot/Bootstrapper
程序员文章站
2022-06-19 14:58:29
异常解决:java.lang.NoClassDefFoundError: org/springframework/boot/Bootstrapper跟着以前的教学视频学习的过程中出现了这个问题,找了好久终于找出了原因,特此记录。问题描述问题发生在springboot去添加spring-cloud的maven依赖包后,启动springboot程序,idea突然报了以下错误:java.lang.NoClassDefFoundError: org/springframework/boot/Bootstra...
异常解决:java.lang.NoClassDefFoundError: org/springframework/boot/Bootstrapper跟着以前的教学视频学习的过程中出现了这个问题,找了好久终于找出了原因,特此记录。
问题描述
问题发生在springboot去添加spring-cloud的maven依赖包后,启动springboot程序,idea突然报了以下错误:
java.lang.NoClassDefFoundError: org/springframework/boot/Bootstrapper
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:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.springframework.cloud.bootstrap.encrypt.DecryptEnvironmentPostProcessor.getTextEncryptor(DecryptEnvironmentPostProcessor.java:83)
at org.springframework.cloud.bootstrap.encrypt.DecryptEnvironmentPostProcessor.postProcessEnvironment(DecryptEnvironmentPostProcessor.java:69)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:177)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:342)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
at com.atguigu.gulimail.product.GuliMailProductApplication.main(GuliMailProductApplication.java:11)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.Bootstrapper
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 27 common frames omitted
原因
本人是使用idea的spring Initializr初始化器去创建的项目,随后将springboot的版本改为了较旧的 springboot 2.1.8 版本,启动后报错
反复寻找之后原来是因为使用spring Initializr创建的时候,一旦你勾中了springCloud有关技术,他会同时引入springCloud依赖版本管理:
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2020.0.0</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
解决
删掉或者或自定义springCloud依赖版本即可
总结
当你使用idea初始化器去创建spring项目,然后你又需要改变当前版本的时候,最好注意maven依赖之间的版本冲突
本文地址:https://blog.csdn.net/shuttle33/article/details/112258314
上一篇: 以诸葛亮的口味和品味来讲,黄月英真的是奇丑无比吗?
下一篇: 前后端分离Java统一响应返回格式
推荐阅读
-
解决rabbitmq无限循环异常问题亲测 Caused by: org.springframework.amqp.AmqpException: No method found for class [B
-
org.springframework.validation.BindException异常解决
-
org.springframework.boot.autoconfigure.*包冲突的解决方案
-
解决java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/RedisStreamCommands
-
异常解决:java.lang.NoClassDefFoundError: org/springframework/boot/Bootstrapper
-
已解决异常:java.lang.NoClassDefFoundError: org/springframework/util/ClassUtils
-
解决:java.lang.NoClassDefFoundError: org/springframework/transaction/ReactiveTransactionManager
-
org.springframework.boot.actuate.endpoint.EndpointId cannot be cast to java.lang.String 异常处理
-
Failed to read artifact descriptor for org.springframework.boot:spring-boot--***解决方法
-
Caused by: org.hibernate.boot.archive.spi.ArchiveException: Could not build ClassFile异常怎么解决