knife4j icon indicating copy to clipboard operation
knife4j copied to clipboard

documentationPluginsBootstrapper NullPointerException issue in springboot 2.6.0

Open zhangchaoxu opened this issue 3 years ago • 10 comments

给遇到相同问题的朋友做个记录。 在springboot 2.6.0会提示documentationPluginsBootstrapper NullPointerException,具体位置的WebMvcPatternsRequestConditionWrapper中的condition为null。

原因是在springboot2.6.0中将SpringMVC 默认路径匹配策略从AntPathMatcher 更改为PathPatternParser,导致出错,解决办法是切换会原先的AntPathMatcher

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

zhangchaoxu avatar Nov 22 '21 05:11 zhangchaoxu

大哥,你真是太牛逼了,我正找这问题呢,登陆点个赞

SimonFuInSky avatar Nov 22 '21 07:11 SimonFuInSky

我都考虑换spring doc了。 springfox长期不更新,想用spring indexer也不行。

beingEggache avatar Nov 24 '21 01:11 beingEggache

我都考虑换 spring doc 了。 springfox 长期不更新,想用 spring indexer 也不行。

springdoc 确实还不错,而且兼容性还行

iPisces77 avatar Nov 26 '21 06:11 iPisces77

Change spring.mvc.pathmatch.matching-strategy default values, don't worry about the impact on other components? Does the Spring community have a list of major impact components?

linghengqian avatar Nov 27 '21 06:11 linghengqian

可以看看这里 https://github.com/springfox/springfox/issues/3462 也可以新建bean解决这个bug,但是会有新问题,那就是与knife4j有兼容问题,会导致knife4j不生成文档具体我还没仔细看

filusilia avatar Dec 01 '21 08:12 filusilia

厉害! 厉害 !给你点赞!!!

FlyITMan avatar Dec 04 '21 09:12 FlyITMan

2.6.2 实测还是有此问题

czy006 avatar Jan 19 '22 08:01 czy006

2.6.2 实测还是有此问题

Springfox has stopped maintenance. If you continue to use the Springfox bottom layer, please stay in the Springboot 2.5.x version. Or use the SpringDoc bottom layer instead.

linghengqian avatar Jan 19 '22 08:01 linghengqian

请问有解决方案了吗?

Hisioni avatar Jan 25 '22 03:01 Hisioni

Spring Boot 2.6.5 + knife4j-spring-boot-starter 2.0.9 用以下的配置才生效了,看了下常量的定义,需要下划线。

spring:
  mvc:
    pathmatch:
      matching-strategy: ANT_PATH_MATCHER

alaahong avatar Mar 29 '22 06:03 alaahong

https://gitee.com/xiaoym/knife4j/issues/I5LIQZ

4.0.0快照版本适配了这种情况

处理代码:https://github.com/xiaoymin/swagger-bootstrap-ui/blob/dev/knife4j/knife4j-openapi2-spring-boot-starter/src/main/java/com/github/xiaoymin/knife4j/spring/common/bean/SpringFoxEnvironmentPostProcessor.java

xiaoymin avatar Dec 03 '22 04:12 xiaoymin

4.1.0还是有这个问题

lucas-tal avatar Jul 31 '23 05:07 lucas-tal