最近新建一个springboot工程,之前的代码移植过来启动却报错了,奇了个怪哉,排查吧.....
对比之前的工程发现springboot版本不同了,于是查找新版办的spring boot是不是有相关方面的配置升级,经过1个小时的“刻苦钻研(百度一下)”,终于被我找到了根本原因是:自spring boot2.6之后,Spring MVC 处理映射匹配的默认策略已从AntPathMatcher更改为PathPatternParser。
当spring boot2.6整合swagger时,还是默认的认为springmvc的路径匹配策略是AntPathMatcher,
当启动时就会报错:
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)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
解决方法:
在yml配置文件中添加对默认路径的修改配置:
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
启动,依旧丝滑.....



