#介绍
#springBoot+Swagger2
#SpringMVC+Swagger2
#生产环境的禁用
介绍
swagger是一个自动生成接口文档的工具,以往都是手写接口文档,难免不了许多出错的地方,swagger的出现大大地减少了开发人员处理这些琐碎时间,能让开发员专注于系统本身工作。swagger能自动生成restful风格的接口文档,并且支持在线测试,也能够为其他接口文档工具提供数据。下面介绍swagger的两种使用方式。
详情到官网https://swagger.io/
springBoot+swagger2
1,pom配置jar包
<!--引入swagger支持-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
2,编写swagger配置代码
package com.wdk.config;
/**
* @Author: DaiKang
* @Description:
* @Date: Created in 2020/1/22 20:45
*/
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spri