springboot 2.7.12 在整合 knife4j 3.0.3 的时候遇到了空指针异常
报错截图:
从网上一搜发现是Spring Boot 2.6以上引入的新PathPatternParser,需要进行配置,不然整合起来会报错
解决方案:
需要在 application.yaml 配置文件中配置
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
从SpringBoot 2.6.0开始,请求路径与Spring MVC处理映射匹配的默认策略采用PathPatternParser,而不是AntPathMatcher,如果不进行配置的话就会报错
api解释说明:
AntPathMatcher:spring路径匹配器
参考文章:https://blog.csdn.net/kkorkk/article/details/123774484