一.使用步骤:
1.导入依赖:
<!--swagger2.9.2,swagger3.0出现了一些改变,和swagger2不同-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
2.开启swagger
@Configuration
@EnableSwagger2
public class SwaggerConfig {
}
3.访问http://localhost:端口名/swagger-ui.html
二、Swagger的使用
1.常见的注释:
2.常用的一些ui界面
https://blog.csdn.net/qq_33369905/article/details/106647288
三、出现异常
Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
解决方案:
因为Springfox 使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher。所以需要在application中配置一下
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher