解决Swagger2 整合spring boot 项目依赖
问题描述
Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
当Spring Boot 2.6.x 和Swagger 3.0.0 整合的时候,
@EnableSwagger2WebMvc后报Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
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.17.jar:5.3.17]
原因分析:
在springboot2.6.x中将SpringMVC 默认路径匹配策略从AntPathMatcher 更改为PathPatternParser,导致出错,解决办法是切换会原先的AntPathMatcher。后者统一版本
解决方案:
在yml 或者properties 文件加上如下配置
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher