Swagger 弹窗问题
springboot整合swagger后,出现一直弹窗问题,如图
在这里插入图片描述
经过查询资料找到可能是如下几个原因

1、在启动的时候没有扫描到Swagger工具类

解决办法:在启动类上添加注解
@ComponentScan(basePackages = {“com.shiguang”})
括号为swagger配置类所在的包
2、配置了拦截器,在拦截器中被拦截了
解决办法:放行swagger的页面,这个具体没试过,查资料的时候在
https://blog.csdn.net/weixin_44154163/article/details/110386934 这个博客看到的

3、在启动类上加 @EnableSwagger2(亲测,这个成功了)

在这里插入图片描述
解决后可能会出现这种问题
org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
在这里插入图片描述

据说是由于因为Springfox使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher,也就是说版本不匹配导致的,解决办法:在配置文件中加上 spring.mvc.pathmatch.matching-strategy= ANT_PATH_MATCHER 就可以了。
以上解决方法全是在各个文章中找到整理的,不保证好用。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐