swagger2搭建
- 引入
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>26.0-jre</version>
</dependency>
- 配置
/**
* Swagger2 配置类
* @author yuanfeng.z
* @date 2019/11/25 16:28
*/
@EnableSwagger2
@Configuration
public class Swagger2Config {
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()// 指定需要展现的api接口
.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)) // 扫描接口
.build();
}
private ApiInfo apiInfo() {
return new ApiInfo("用户服务",
"用户服务",
"v0.0.1",
"",
null,
"",
"",
new ArrayList<>());
}
}
- 描述类
@Api(tags = "会员管理")
- 描述接口
@ApiOperation(value = "register", notes = "注册", httpMethod = "POST")
https://blog.csdn.net/liuchuanhong1/article/details/59064794
https://blog.csdn.net/liuchuanhong1/article/details/58594045
网友评论