1. swagger2是什么
swagger是一个RESTFUL 接口的文档在线自动生成和功能测试的框架
2. Springboot整合Swagger2
1.创建springboot项目
2.添加依赖
<!-- Swagger API文档 -->
<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>
3.添加Swagger2配置类SwaggerConfig
@SpringBootApplication@MapperScan("com.zking.swaggerdemo.mapper")
@EnableSwagger2
@ComponentScan("com.zking.swaggerdemo.utils")
4.API接口编写
5.SpringBoot启动成功后,访问http://localhost:8090/swagger-ui.html即可
成功的效果: