swagger2+springboot(2.6.0+)异常

swagger2(2.9.2) + springboot(2.6.0+)报错:

提示:这里简述项目相关背景:

springboot2.6与swagger2.9.2整合 报出空指针异常的,


org.springframework.context.ApplicationContextException: 
	Failed to start bean 'documentationPluginsBootstrapper'; 【重点】
	nested exception is java.lang.NullPointerException
	//中间错误信息省略
Caused by: java.lang.NullPointerException: null		【重点】
	at springfox.documentation.spi.service.contexts.Orderings$8.compare(Orderings.java:112) ~[springfox-spi-2.9.2.jar:null]
	at springfox.documentation.spi.service.contexts.Orderings$8.compare(Orderings.java:109) ~[springfox-spi-2.9.2.jar:null]
	

解决方案:

是因为springboot2.6.0 中将SpringMVC 默认路径匹配策略从AntPathMatcher更改为PathPatternParser application.properties(或application.yml)配置文件中加上这个路径配置
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
原因:springboot中请求路径与 Spring MVC 处理映射匹配的默认策略已从AntPathMatcher更改为PathPatternParser,需要更改回去,适应swagger中请求路径.

补充

一般空指针异常,都是数据找不到的情况的概率大点,如果下次遇到类似的问题,可以考虑路径配置关系,但前提要静下心来,研究每个小bug

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值