问题:在springboot项目中添加swagger后,启动时报错:org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
原因:使用的springboot版本高于2.6.X,springboot2.6.0以后,使用的Spring MVC 处理映射匹配的默认策略从AntPathMatcher更改为PathPatternParser;
解决办法:
方法一:使用springboot2.6.0以下版本(不推荐)
方法二:在yml配置文件中添加(改变默认的映射匹配策略):
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher