项目场景:
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
原因分析:
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

当Springboot集成Swagger2后启动出现'Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException'的错误,原因在于Springboot 2.6以后更改了路径匹配策略。解决办法是在application.properties或application.yml中添加配置:spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER,将匹配策略恢复为ANT_PATH_MATCHER。

1261

被折叠的 条评论
为什么被折叠?



