解决:启动springboot项目,Unable to start web server; nested exception is org.springframework.beans.factory

解决:启动springboot项目,出现异常:Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryConfiguration$EmbeddedTomcat': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationPropertiesBean

一·问题描述:

(1)启动springboot项目,报异常完整如下图:但是在导入springcloud组件依赖之前,却是可以正常启动springboot项目

在这里插入图片描述

(2)springboot项目中导入了springcloud相关微服务组件依赖:

在这里插入图片描述
在这里插入图片描述

二·异常原因:

(1)根本原因:springboot父工程的依赖版本,与springcloud某个组件依赖版本不匹配。

(2)直接原因:利用IDEA快捷创建boot项目且导入某个cloud组件依赖时。IDEA会默认使用最新版本组件(包括boot项目也会使用最新版本创建),后面一旦改动boot项目版本就会导致两者之间的版本冲突。

三·解决办法:

(1)查看cloud版本与boot项目版本的匹配图:(cloud官网也可以查看)

在这里插入图片描述
注意:上图两侧显示的都是大体版本对应。实际生产时,都需要从某个大体版本中,随便导入一个具体版本依赖。

#版本对应举例如下:

boot项目版本:2.1.8.RELEASE
cloud组件版本:Greenwich.SR3

(2)再根据boot项目,从maven仓库中导入合适版本的依赖(cloud官网也可以,只要你会看)

本人boot项目是2.1开头的:因此需要选择Greenwich开头的版本依赖
在这里插入图片描述
在这里插入图片描述

(3)将从maven仓库中复制的版本依赖,粘贴到boot项目中去

在这里插入图片描述

四·测试结果:

(1)boot项目正常启动

在这里插入图片描述

(2)浏览器也能正常访问响应

在这里插入图片描述

五·注意:

(1)当boot项目中导入cloud组件时,尤其需要注意两者之间的版本是否匹配!!!

(2)boot项目中只要存在一个cloud组件版本与boot项目版本不匹配,都会出现很多异常,包括无法启动。

  • 24
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
引用\[1\]和\[2\]中提到的报错信息是关于Spring Boot应用程序启动时无法启动Web服务器的问题。具体的错误信息是"Unable to start web server; nested exception is org.springframework.context.ApplicationContextException"。这个错误通常是由于缺少ServletWebServerFactory bean引起的。引用\[3\]中提到的解决方法是在启动类之前添加@EnableAutoConfiguration注解来解决这个问题。 根据报错信息和解决方法,可以推断出问题的原因是缺少ServletWebServerFactory bean。解决方法是在启动类上添加@EnableAutoConfiguration注解。这个注解可以帮助Spring Boot自动配置所需的bean,包括ServletWebServerFactory bean,以便启动Web服务器。 所以,你遇到的问题是由于缺少ServletWebServerFactory bean引起的。你可以尝试在启动类上添加@EnableAutoConfiguration注解来解决这个问题。 #### 引用[.reference_title] - *1* [gateway网关启动报错 uable to start web ... nested exception is org.springframework.context.Application](https://blog.csdn.net/qq_37158147/article/details/126907742)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [已解决SpringBoot启动报错:Unable to start web ... nested exception is org.springframework.boot.web](https://blog.csdn.net/qq_43408367/article/details/128361675)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [SpringBoot报错:Unable to start web ... nested exception is org.springframework.context.Application](https://blog.csdn.net/dl962454/article/details/105881089)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ideal-cs

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值