栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Swagger配置时版本不兼容问题引起的Bug:Failed to start bean ‘documentationPluginsBootstrapper‘

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Swagger配置时版本不兼容问题引起的Bug:Failed to start bean ‘documentationPluginsBootstrapper‘

在给SpringBoot项目配置Swagger时出现了一个很令人费解的Bug,这种因为版本不兼容出现的bug时真的让人蛋疼!!

首先介绍一下spring-boot-starter-parent是什么:(以2.6.2版本为例)

参考链接:https://blog.csdn.net/qq_37606901/article/details/105906112


        org.springframework.boot
        spring-boot-starter-parent
        2.6.2
         

可以从源码中看到里面配置了一些基本的信息:

  • 定义了 Java 编译版本,如上为 1.8。
  • 使用 UTF-8 格式编码
  • maven源文件和目标文件编译的版本
  • 执行打包操作的配置
  • 自动化的资源过滤
  • 自动化的插件配置
  • spring-boot-starter-parent的parent是spring-boot-dependencies

   再看看spring-boot-dependencies,发现里面定义了很多版本号,这个也就是pom文件里面有些依赖我们不必须写或者不需要写版本号的原因

 然后说回重点:Swagger配置后出现的Bug!

当我在给SpringBoot项目中配置Swagger的依赖时Bug就出现了,以下是pom.xml文件中spring-boot-starter-parent与Swagger的配置信息


        org.springframework.boot
        spring-boot-starter-parent
        2.6.2
         

    io.springfox
    springfox-swagger2
    2.9.2


     io.springfox
     springfox-swagger-ui
     2.9.2

然后配置完后:启动SpringBoot出现以下Bug

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-29 23:10:47.911 ERROR 7124 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.14.jar:5.3.14]
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.14.jar:5.3.14]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.14.jar:5.3.14]
    at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_202]

乍一看是空指针异常! 但是项目中我什么代码都没有! 所以只可能是版本原因,将spring-boot-starter-parent的版本降低为2.3.4.RELEASE! 问题解决!


        org.springframework.boot
        spring-boot-starter-parent
        2.3.4.RELEASE
         

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/684406.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号