SpringBoot2.7整合Swagger3.0报错
AI 摘要鱼粮不足,AI 今天先歇着 · 正文在下面
问题
今天把某个项目的SpringBoot和Swagger做了升级,启动报了:Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

解决
经过查阅资料,发现springboot2.6之后更改了请求路径与与SpringMVC路径匹配规则,已经不是原来的AntPathMatcher了,改为了PathPatternParser。可能Swagger3.0还没有做兼容吧,不过也挺久了。。

如果你是application.properties,加这个参数
properties
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
如果你是application.yml,加这个参数
yml
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
补充
1 swagger3.0访问地址:http://localhost:8888/swagger-ui/index.html
2. swagger3.0要将@EnableSwagger2注解改为@EnableOpenApi
评论
0 条—
还没有评论,来说第一句