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

2年前 (2022) 程序员胖胖胖虎阿
244 0 0

解决:启动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官网也可以查看)
    • (2)再根据boot项目,从maven仓库中导入合适版本的依赖(cloud官网也可以,只要你会看)
    • (3)将从maven仓库中复制的版本依赖,粘贴到boot项目中去
  • 四·测试结果:
    • (1)boot项目正常启动
    • (2)浏览器也能正常访问响应
  • 五·注意:
    • (1)当boot项目中导入cloud组件时,尤其需要注意两者之间的版本是否匹配!!!
    • (2)boot项目中只要存在一个cloud组件版本与boot项目版本不匹配,都会出现很多异常,包括无法启动。

一·问题描述:

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

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

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

解决:启动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

二·异常原因:

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

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

三·解决办法:

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

解决:启动springboot项目,Unable to start web server; nested exception is org.springframework.beans.factory
注意:上图两侧显示的都是大体版本对应。实际生产时,都需要从某个大体版本中,随便导入一个具体版本依赖。

#版本对应举例如下:

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

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

本人boot项目是2.1开头的:因此需要选择Greenwich开头的版本依赖
解决:启动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

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

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

四·测试结果:

(1)boot项目正常启动

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

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

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

五·注意:

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

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

相关文章

暂无评论

暂无评论...