项目场景:


springboot 集成Swagger2启动报错

Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException

问题描述

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

问题意思百度得来大概为以下意思

org.springframework.context.ApplicationContextException: 无法启动 bean 'documentationPluginsBootstrapper';嵌套异常是java.lang.NullPointerException


原因分析:


Springboot2.6以后将SpringMVC 默认路径匹配策略从AntPathMatcher 更改为PathPatternParser,导致出错


解决方案:


在配置文件application.properties中加入以下配置

spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

如果是application.yml就加入

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐