springboot v2.6.1 无法整合 knif4j

OSC年度开源问卷新鲜出炉,你的回答对我们很重要,参与开源可以从这份问卷开始>>>

在springboot v2.6.1 中使用knif4j 开放文档,会导致项目无法启动,文档无法形成。

> Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.toString()" because the return value of "springfox.documentation.spi.service.contexts.Orderings.patternsCondition(springfox.documentation.RequestHandler)" is null

回答

Springboot2.6以后将SpringMVC 默认路径匹配策略从AntPathMatcher 更改为PathPatternParser,导致出错,解决办法是切换会原先的AntPathMatcher。

spring.mvc.pathmatch.matching-strategy=ant-path-matcher

设置了这个参数还是不行呢?还有其他注意项吗?谢谢